속성 설정자에서 Variant
으로 선언 된 클래스 필드 변수에 UnicodeString
(또는 Widestring
, 시도했습니다) 값을 할당하려고합니다. 내가 System.Variants
을 포함 한 interface
uses
절에서Delphi XE5에서 Variant 변수에 문자열을 할당 할 수 없습니까?
EVariantBadVarTypeError - 'Invalid variant type'
: 나는 오류를 받고 있어요.
가 여기에 Variant
필드 변수의 내 선언입니다 :
// Items is a TObjectList descendant
// each item in items is an instance of TInnerClass
TInnerClass(Items[Index]).AsString := StringList[Index];
// at runtime value is for ex. 'Dr.' - this assignment raises the above referenced exception
: 여기
procedure TContainerClass.TInnerClass.SetAsString(const AValue: UnicodeString);
begin
FValue := AValue;
end;
이 속성을 사용하는 예입니다
여기
implementation
섹션에서
TContainerClass = class(TObject)
strict private
...
type
...
TInnerClass = class
strict private
...
FValue: Variant;
function GetAsString: UnicodeString;
...
procedure SetAsString(const Value: UnicodeString);
public
...
property AsString: UnicodeString read GetAsString write SetAsString;
...
end;
...
end;
내 속성 setter입니다
코드를 진행하면서 모든 객체는 제정되었다. 과제의 양면이 유효한 것으로 보입니다. 내가 부족 간단
아마(Unknown type: 39852, (nil,$3A83700), Variant array of Unknown, $1, $F, '')
뭔가 : 단계별 때 눈치 유일한 것은 내가 TInnerClass(Items[Index])
을 평가할 때이를 볼 수 있다는 것입니다.
유효한 개체 인스턴스가 있습니까? –