相关疑难解决方法(0)

Cocoa Objective-c Property 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 …
Run Code Online (Sandbox Code Playgroud)

cocoa structure properties objective-c

10
推荐指数
1
解决办法
7345
查看次数

标签 统计

cocoa ×1

objective-c ×1

properties ×1

structure ×1