我想更改變量值,它是另一個類的結構的成員。 但價值沒有得到改變。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