由数组引起的SIGABRT
当我单击 nextIdea() 按钮时,出现错误,突出显示 int retVal = UIApplicationMain(argc, argv, nil, nil)
并显示 SIGABRT
- (IBAction)nextIdea:(id)sender
{
int index = arc4random() % ideaArray.count;
ideaTextView.text = [NSString stringWithFormat:@"%@",[ideaArray objectAtIndex:index]];
}
- (void)viewDidLoad
{
[super viewDidLoad];
PFQuery *query = [PFQuery queryWithClassName:@"Ideas"];
[query whereKey:@"Hidden" equalTo:@"entry"];
[query getObjectWithId:@"Idea"];
ideaArray = [[[NSArray alloc] init] autorelease];
// ideaArray = [query findObjects];
ideaArray = [NSArray arrayWithObjects:@"one", @"two", nil];
}
我已经尝试解决这个问题几个小时了但没有运气。
ideaArray 在标头中声明并合成 btw
确切的错误消息:
[15842:f803] application:didFailToRegisterForRemoteNotificationsWithError: Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator" UserInfo=0x6a5e500 {NSLocalizedDescription=remote notifications are not supported in the simulator}
在设备上时,错误读取:
Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x19f4f0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
When I click the button for nextIdea(), I get an error that highlights int retVal = UIApplicationMain(argc, argv, nil, nil)
and says SIGABRT
- (IBAction)nextIdea:(id)sender
{
int index = arc4random() % ideaArray.count;
ideaTextView.text = [NSString stringWithFormat:@"%@",[ideaArray objectAtIndex:index]];
}
- (void)viewDidLoad
{
[super viewDidLoad];
PFQuery *query = [PFQuery queryWithClassName:@"Ideas"];
[query whereKey:@"Hidden" equalTo:@"entry"];
[query getObjectWithId:@"Idea"];
ideaArray = [[[NSArray alloc] init] autorelease];
// ideaArray = [query findObjects];
ideaArray = [NSArray arrayWithObjects:@"one", @"two", nil];
}
I've been trying to figure this out for hours but have no luck.
ideaArray is declared in the header and synthesized btw
Exact error message:
[15842:f803] application:didFailToRegisterForRemoteNotificationsWithError: Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator" UserInfo=0x6a5e500 {NSLocalizedDescription=remote notifications are not supported in the simulator}
When on the device, error reads:
Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x19f4f0 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非将
ideaArray
存储为类变量,否则您将无法从nextIdea:
方法访问它。ideaArray
成为该类的属性。self.ideaArray
从nextIdea:
方法访问数组。Unless you store the
ideaArray
as a class variable, you will not be able to access it from thenextIdea:
method.ideaArray
a property of the class.self.ideaArray = [NSArray arrayWithObjects:@"one", @"two", nil];
notation. The self will refer to the property you have created.nextIdea:
method usingself.ideaArray
.该属性设置为(非原子,分配),只需将分配更改为复制,并且它可以工作
The property was set to (nonatomic, assign), just changed assign to copy, and it works