为了账号安全,请及时绑定邮箱和手机立即绑定

NSMutableArray加载项不影响计数?

NSMutableArray加载项不影响计数?

C#
慕姐8265434 2019-11-06 09:05:31
NSMutableArray加载项不影响计数?有人能告诉我为什么即使我在日志中添加对象,日志记录(Sel.giftiescount)仍然返回0吗?标题:#import <UIKit/UIKit.h>@interface Test2AppDelegate : NSObject <UIApplicationDelegate>  {     UIWindow *window;     NSMutableArray *giftees;}@property (nonatomic, retain) UIWindow *window;@property (nonatomic, retain) NSMutableArray *giftees;@end电话:- (void)bootstrapGiftees{     NSArray *gifteeNames = [NSArray arrayWithObjects:@"Jesse",,nil];     for (NSString *gifteeName in gifteeNames)     {         GifteeModel *g = [[GifteeModel alloc] init];         g.name = gifteeName;         [self.giftees addObject:g];         NSLog(@"giftees count = %d", [self.giftees count]);         [g release];}}
查看完整描述

2 回答

?
largeQ

TA贡献2039条经验 获得超7个赞

因为您很可能根本就没有初始化giftors数组,所以当代码运行时,它仍然是零。

查看完整回答
反对 回复 2019-11-07
?
繁花不似锦

TA贡献1851条经验 获得超4个赞

“赠与者”初始化了吗?如果为零,则[赠品计数]也将返回0。

查看完整回答
反对 回复 2019-11-07
  • 2 回答
  • 0 关注
  • 337 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信