小编Sim*_*nen的帖子

为什么cocoa到处都没有使用相同的枚举声明风格?

我想知道可可的不同风格的枚举声明背后的理由是什么?

像这样:

enum { constants.. }; typedef NSUInteger sometype;
Run Code Online (Sandbox Code Playgroud)

是否有理由使用typedef来获取NSUInteger的分配而不进行强制转换?

有时typedef是NSInteger/NSUInteger,为什么不总是使用NSInteger?使用NSUInteger真的有好处吗?

枚举标记名有时仍然使用,就像这里的_NSByteOrder.

这个答案也非常有用:Objective-C中的typedef枚举是什么?.

cocoa objective-c nsinteger nsuinteger

12
推荐指数
2
解决办法
3507
查看次数

NSNotificationCenter通知是否比UITableView单元加载事件具有更高的优先级?

是否在UI更新事件之前处理了NSNotificationCenter postNotificationName发布的事件?

我需要知道,否则我的当前程序会在极少数情况下崩溃.

型号代码:

- (void)searchFinishedWithResults:(Results *)results {
    self.results = results;
    // If some table cells are loaded NOW, before notication is processed, we might crash!
    [[NSNotificationCenter defaultCenter]
     postNotificationName:SearchResultArrived object:nil];    
}
Run Code Online (Sandbox Code Playgroud)

处理通知时,我将运行UITableView reloadData.

但是,请考虑在处理通知之前,是否必须更新UI.在这种情况下,-tableView:cellForRowAtIndexPath:将调用indexPath,但结果对象已更改,它将获取旧数据.

iphone objective-c

3
推荐指数
1
解决办法
1870
查看次数

标签 统计

objective-c ×2

cocoa ×1

iphone ×1

nsinteger ×1

nsuinteger ×1