相关疑难解决方法(0)

初始化属性,点符号

在我的init方法中使用点表示法将retain属性初始化为nil是不是一个坏主意?

对于像这样的普通房产:

@property (nonatomic, retain) id foo;
Run Code Online (Sandbox Code Playgroud)

在我设置的init方法中说self.foo = nil.合成的方法首先释放或自动释放foo(不完全确定潜在的实施).被fooguaranted第一setter或getter调用之前是零?或者它会指向随机垃圾,除非我明确设置foo = nil没有点符号?

initialization properties reference-counting objective-c dealloc

20
推荐指数
1
解决办法
1万
查看次数

类属性mVar和实例变量self.mVar之间的区别

我对于通过self访问实例变量或仅通过名称(在类中工作时)之间的区别感到困惑.

例如,参加这个课程:

//In .h file:
@interface Register : NSObject {
    NSString *mName;
}

- (id) initWithName:(NSString *) name;

//In .m file:
- (id) initWithName:(NSString *)name
{
    if (self == [super init])
    {
        mName = name;
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

通过访问实例变量之间的区别是什么

self.mName = name;
Run Code Online (Sandbox Code Playgroud)

VS

mName = name;
Run Code Online (Sandbox Code Playgroud)

哪个不是@property而且不是@ sythenize'd.

说这是这个,但是这个例子:

//In .h file:
@interface Manange_My_ViewsViewController : UIViewController { 
    IBOutlet UILabel *countLabel;
}

@property (nonatomic, retain) IBOutlet UILabel *countLabel;

//In .m file:
@synthesize countLabel;

- (void) updateLabel:(NSUInteger)count
{
    countLabel.text = [NSString …
Run Code Online (Sandbox Code Playgroud)

oop iphone objective-c self core-foundation

4
推荐指数
1
解决办法
1343
查看次数