iphone - 每当我尝试运行此代码时,iPhone都会崩溃

标签 iphone ios objective-c nsarray ibaction

因此,我试图在我的iPhone应用程序中运行此代码,但该应用程序始终崩溃。有什么办法吗?

- (IBAction)logOutBtnDown:(id)sender {
    [PFUser logOut];
    NSArray *quotes;
    int r;

    quotes = [NSArray arrayWithObjects:
        @"R u done yet",
        @"Log in again",
        @"Try Me",
        @"SMD",
        @"We can do this all day",
        @"IDC your eating up ur RAM",
        "Please just connect to the servers",
        @"You are not giving up are u",
        @"Forget it I quit",
        @"Imma tell TDK",
        nil];

    r = arc4random() % 10;
    [_welcomeLabel setText:[NSString stringWithFormat:@" %@", [quotes objectAtIndex: r]]];
}

最佳答案

添加对象时错过了@,

试试这个

- (IBAction)logOutBtnDown:(id)sender {
  [PFUser logOut];
NSArray *quotes;
int r;

quotes = [NSArray arrayWithObjects: @"R u done yet", @"Log in again", @"Try Me", @"SMD", @"We can do this all day", @"IDC your eating up ur RAM", @"Please just connect to the servers", @"You are not giving up are u", @"Forget it I quit", @"Imma tell TDK", nil];

r = arc4random() % 10;


[_welcomeLabel setText:[NSString stringWithFormat:@" %@", [quotes objectAtIndex: r]]];

}

关于iphone - 每当我尝试运行此代码时,iPhone都会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14411050/

相关文章:

java - 谷歌云消息 : don't receive alerts when iOS App is in background

objective-c - 从另一个类调用函数

iphone - 如何创建 iphone 密码查看

iphone - 无法从 iPhone 访问打开购物车管理员

ios - 使用 iMovie 创建 iOS 应用程序预览

ios - 仅在 iphone 4 上的 Cordova 应用程序元素移动

android - flutter : How to get the format of the scanned barcode using flutter?

ios - 按 UIImage 打开新的 View Controller

iphone - ffmpeg avformat_open_input 在设备中不工作

iphone - 如何检测 iPhone 上的内存泄漏?