lxx84688098
JimmyStudio
2016-01-17 13:58

(IOS)这两种写法有什么区别???

  • object-c
  • ios

两种写法有一种运行后加载不了数据...
第一种:
-(NSArray *)messageFrames
{
if (_messageFrames == nil) {
NSArray *messages = [Message messagesList];
NSMutableArray *temArray =[NSMutableArray array];
for (Message *msg in messages) {
MessageFrame *msgframe = [[MessageFrame alloc] init];
msgframe.message = msg;
[temArray addObject:msgframe];
}
_messageFrames = temArray;
}
return _messageFrames;
}
第二种
-(NSArray *)messageFrames
{
NSArray *messages = [Message messagesList];
NSMutableArray *temArray =[NSMutableArray array];
if (_messageFrames == nil) {
for (Message *msg in messages) {
MessageFrame *msgframe = [[MessageFrame alloc] init];
msgframe.message = msg;
[temArray addObject:msgframe];
}
}
_messageFrames = temArray;
return _messageFrames;
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐