作者:男孩艹艹 | 来源:互联网 | 2023-10-12 18:43
I'm really new to iOS development and I'm trying to create a simple table view, so I added a Table View Controller, added my custom class to it and now I was trying to add items.
我真的很喜欢iOS开发,我正在尝试创建一个简单的表视图,所以我添加了一个表视图控制器,添加了我的自定义类,现在我正在尝试添加项目。
So I created a new array:
所以我创建了一个新数组:
@property (nonatomic, strong) NSMutableArray *activity;
And I the viewDidLoad, I tried adding some items to the array:
我是viewDidLoad,我尝试在数组中添加一些项目:
for(int i = 0; i <20; i++)
{
NSLog(@"Current item: %u", i);
Item *item = [[Item alloc] init];
item.time = @"14:30";
item.text = @"A simple test";
item.startedAgo = @"yesterday";
item.project = @"testProject";
[self.activity addObject:item];
}
NSLog(@"Activity count: %u", [self.activity count]);
The log seems to be fine, excpet when I try to output the lenght of the array, it stays 0
日志似乎很好,当我尝试输出数组的长度时,它会保持为0
2012-05-02 14:12:50.772 coop_dev[15352:f803] Current item: 0
2012-05-02 14:12:50.772 coop_dev [15352:f803]当前项目:0
...
2012-05-02 14:12:50.783 coop_dev[15352:f803] Current item: 19
2012-05-02 14:12:50.783 coop_dev [15352:f803]当前项目:19
2012-05-02 14:12:50.784 coop_dev[15352:f803] Activity count: 0
2012-05-02 14:12:50.784 coop_dev [15352:f803]活动计数:0
Am I missing something here?
我在这里错过了什么吗?
2 个解决方案