我想更改变量值,它是另一个类的结构的成员。 但价值没有得到改变。Cocoa Objective-c属性C结构赋值失败
这是代码。
//Structure..
typedef struct {
int a;
double b;
} SomeType;
//Class which has the structure as member..
@interface Test2 : NSObject {
// Define some class which uses SomeType
SomeType member;
}
@property SomeType member;
@end
@implementation Test2
@synthesize member;
@end
//Tester file, here value is changed..
@implementation TesstAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
Test2 *t = [[Test2 alloc]init];
t.member.a = 10;
//After this the value still shows 0
}
@end
我试过了下面的链接。
Structure as a class member in Objective C
问候, Dhana。
哦,'t.member.a'对于'member.a'的值来说就好了。这与'[t member] .a'完全相同。 – 2010-03-11 20:07:20
是啊,它工作正常.. 我试图做的一切在一个步骤.. – Dhanaraj 2010-03-12 04:18:07
你知道什么是声音,殿下?这些都是尖锐的C#开发人员。如果你不相信我,就等着。当他们即将在Objective-C中使用点符号时,它们会变得越来越响亮! http://www.youtube.com/watch?v=Tfo3nEZHNLk – Steve 2011-10-31 00:13:10