objective-c - 字符串问题

标签 objective-c ios xcode xcode4

菜鸟提出的一个非常愚蠢的问题。

我有一个操作,用于设置标签的字符串。

- (IBAction)changeProductText:(NSString *)str{ lblProductTxt.text = str; }

这是我想要将其设置为的字符串:

TestText = [NSString stringWithFormat:@"Hi"];

这就是我正在做的事情:

[self.navigationController pushViewController:nextController animated:YES];

[nextController changeProductText:TestText];

我的问题是它不会将字符串设置为字符串中随机的任何内容。当我点击单元格时它可能会崩溃,但也可能不会,所以我做错了。

最佳答案

stringWithFormat 为您提供了自动释放的格式,没有看到更多代码,我猜它会命中自动释放池,并且您正在尝试访问字符串的垃圾。

关于objective-c - 字符串问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7224992/

相关文章:

ios - ViewControllers 未针对 3.5 英寸屏幕调整大小

javascript - Cordova 2.9、3.0 没有 console.log

ios - 从 NSCalendar 组件获取小时、分钟、秒? ( swift )

xcode - Swift - 我如何从 ViewController 转到 TabBarController

iphone - 测量两个 iOS 设备之间的距离

ios - uiscrollview 中的 UIViewControllers 调用 viewdidappear

ios - 用户滚动 UITableView 后 UITableViewCell 动画消失

iphone - 检查与 NSURLConnection 连接的有效 IP

ios - 尝试呈现模态视图 Controller 时的 UIViewControllerHierarchyInconsistency

objective-c - objective c 类别的范围是什么