0

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}
Chris
  • 7,270
  • 19
  • 66
  • 110
  • Where in your code do you release the array? Do you Dealloc it? Because that would be wrong. Usually retVal indicates a call to a nil object. – CodaFi Nov 15 '11 at 04:28
  • I don't, when I did release it in -dealloc, it gave me EXC_BAD_ACCESS. Without releasing it gives me SIGABRT – Chris Nov 15 '11 at 04:30
  • What does the SIGABRT say? Deallocing an auto released object is a no-no. – CodaFi Nov 15 '11 at 04:30
  • I just added in the error message. I also tried doing it without autorelease, but that didn't work either. – Chris Nov 15 '11 at 04:33
  • 1
    The error is exactly what it says. In order to use APN notifications, one must test on a physical device. Sorry, but all I can say is comment out your APN service code until you have a test device. – CodaFi Nov 15 '11 at 04:35
  • It stills errs when on the device – Chris Nov 15 '11 at 04:41
  • For the device error, check here: http://stackoverflow.com/questions/5681172/bundle-identifier-and-push-certificate-aps-environment-entitlement-error (this is my final post, I do not wish to extend the comments section any further. Good luck) – CodaFi Nov 15 '11 at 04:45
  • Are you sure that it has nothing to do with the allocation? If you don't use `self` during allocation (in the viewDidLoad), you can't really access it from the `nextIdea:` method. Can you just try using `self.ideasArray = [NSArray arrayWithObjects:@"one", @"two", nil];` ? – Guven Nov 15 '11 at 05:35
  • I did try that, it returns with EXC_BAD_ACCESS – Chris Nov 15 '11 at 13:52

2 Answers2

0

Unless you store the ideaArray as a class variable, you will not be able to access it from the nextIdea: method.

  1. Make the ideaArray a property of the class.
  2. When you allocate the array, use the self.ideaArray = [NSArray arrayWithObjects:@"one", @"two", nil]; notation. The self will refer to the property you have created.
  3. Access the array from the nextIdea: method using self.ideaArray.
Guven
  • 2,280
  • 2
  • 20
  • 34
0

The property was set to (nonatomic, assign), just changed assign to copy, and it works

Chris
  • 7,270
  • 19
  • 66
  • 110