【发布时间】:2009-07-14 00:20:40
【问题描述】:
(在 iPhone Objective-C 中编程)
我创建了一个类级别的 NSString*,为其添加属性(非原子,保留)并合成代码,我可以使用 stringByAppendingString 函数无休止地修改字符串,并使用 NSLog 显示字符串就好了。所有这些都是在一个子类中完成的,被覆盖的 viewDidLoad 函数。当我在确定要在 tableView 的单元格中显示什么时尝试从 cellForRowAtIndexPath 函数访问相同的变量时,程序崩溃。谁有线索?
相关代码:
@interface InfoViewController : UITableViewController {
NSString *shipAddr;
}
@property (nonatomic,retain) NSString *shipAddr;
@synthesize shipAddr;
VIEWDIDLOAD:
shipAddr = [[[NSString alloc] initWithString:@""] retain];
**在这里崩溃:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(shipAddr);
**
【问题讨论】:
标签: iphone uitableview nsstring