我是Objective-C的新手所以如果这个问题很愚蠢,请原谅我!但我想知道这意味着什么.
- (void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
}
Run Code Online (Sandbox Code Playgroud)
这些线在详细视图控制器中的作用是什么?这是否意味着一个新对象,即newDetailItem创建并分配给已存在的对象detailItem?我不明白它.
要么
它实际上是否意味着这个新对象已经等同于"detailItem"中存在的细节.所以,不应该写成newDetailItem = _detailItem,所以这个新对象将得到的值_detailItem?
这让我有点困惑:(
谢谢你的时间!
我是Objective-C的新手,当我练习书练习时,我真的被困在这里.请帮我解决这个问题,我一直在考虑什么可能导致这个错误超过三个小时.我仍然没有得到它!
最好的问候,Raj.
提前致谢 !
的main.m
#import <Foundation/Foundation.h>
#import "XYZPerson.h"
#import "XYZShout.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
//XYZPerson *some = [[XYZPerson alloc]init];
XYZShout *some = [[XYZShout alloc]init];
[some sayHello];
// insert code here...
// NSLog(@"Hello, World!");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
XYZPerson.h
#import <Foundation/Foundation.h>
@interface XYZPerson : NSObject
@property NSString *firstName;
@property NSString *secondName;
@property NSDate *dob;
-(void) saySomething;
-(void) sayHello;
@end
Run Code Online (Sandbox Code Playgroud)
XYZPerson.m
#import "XYZPerson.h"
@implementation XYZPerson
-(void) sayHello {
[self saySomething:@"Hello all"];
}
-(void) saySomething:(NSString *)greet …Run Code Online (Sandbox Code Playgroud)