开发者

Abort on iPhone simulator

I am receiving an SIGABRT error on the last line of this code loginButton.enabled = YES;. It was working this morning and now this error comes up.

-(IBAction)login:(id)sender
{
    UIButton *loginButton = (UIButton *)sender;
    loginButton.enabled = NO;
    NSString *filePath = [self dataFilePath];
    if([[NSFileManager defaultManager] fileExistsAtPath:filePath])
    {
        NSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath];
        NSString *nameString = [[NSString alloc] init];
        NSString *contactIdString = [[NSString alloc] init];
        NSString *genderString = [[NSString alloc] init];
        NSString *contactTypeString = [[NSString alloc] init];
        nameString = [array objectAtIndex:0];
        contactIdString = [array objectAtIndex:1];
        genderString = [array objectAtIndex:2];
        contactTypeString = [array objectAtIndex:3];

        self.name = nameString;
        self.contactId = contactIdString;
        self.gender = genderString;
        self.contactType = contactTypeString;
        [self.userArray removeAllObjects];
        [self performSelectorInBackground:@selector(sendData) withObject:nil];

        [nameString release];
        [contactIdString release];
        [genderString release];
        [contactTypeString release];

        UIBarButtonItem *logoutButton = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStylePlain target:self action:@selector(logout:)];

        //[logoutButton setTitle:@"Logout"];  
        [[self navigationItem] setRightBarButtonItem:logoutButton];
        [logoutButton release];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New User" message:@"It seems you have not used FaceDirectory before, please go to My Details and fill out the information then click save." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
    loginButton.enabled = YES;
}

Here is the error dump.

2011-08-12 11:41:56.700 FaceConnect[1651:207] Reachability Flag Status: -R ------- networkStatusForFlags
2011-08-12 11:41:59.247 FaceConnect[1651:207] selected first row
2011-08-12 11:42:02.344 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7a0cf10 of class NSConcreteMutableData autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.344 FaceConnect[1651:207] -[__NSCFData setEnabled:]: unrecognized selector sent to instance 0x6f4b820
2011-08-12 11:42:02.344 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7a108b0 of class NSConcreteMutableData autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.344 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7e06e70 of class NSConcreteMutableData autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.344 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7e06220 of class NSConcreteMutableData autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.345 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7e06ca0 of class NSConcreteMutableData autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.345 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7e068c0 of class NSURL autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.345 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7e061c0 of class NSMutableURLRequest autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.345 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7e069e0 of class NSCFString autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.345 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7e06b30 of class NSCFString autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.345 FaceConnect[1651:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCF开发者_如何学JAVAData setEnabled:]: unrecognized selector sent to instance 0x6f4b820' *** Call stack at first throw: (
        0   CoreFoundation       0x0249d919 __exceptionPreprocess + 185
        1   libobjc.A.dylib      0x025eb5de objc_exception_throw + 47
        2   CoreFoundation       0x0249f42b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
        3   CoreFoundation       0x0240f116 ___forwarding___ + 966
        4   CoreFoundation       0x0240ecd2_CF_forwarding_prep_0 + 50
        5   FaceConnect          0x0000a7ea -[HubViewController login:] + 1802
        6   UIKit                0x00123e14 -[UIApplication sendAction:to:from:forEvent:] + 119
        7   UIKit                0x0032b14b-[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
        8   UIKit                0x00123e14 -[UIApplication sendAction:to:from:forEvent:] + 119
        9   UIKit                0x001ad6c8 -[UIControlsendAction:to:forEvent:] + 67
        10  UIKit                0x001afb4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] +527
        11  UIKit                0x001ae6f7 -[UIControltouchesEnded:withEvent:] + 458
        12  UIKit                0x001472ff -[UIWindow _sendTouchesForEvent:] + 567
        13  UIKit                0x001291ec -[UIApplication sendEvent:] + 447
        14  UIKit                0x0012dac4 _UIApplicationHandleEvent + 7495
        15  GraphicsServices     0x02924afa PurpleEventCallback + 1578
        16  CoreFoundation       0x0247edc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__+ 52
        17  CoreFoundation       0x023df737__CFRunLoopDoSource1 + 215
        18  CoreFoundation       0x023dc9c3 __CFRunLoopRun + 979
        19  CoreFoundation       0x023dc280 CFRunLoopRunSpecific + 208
        20  CoreFoundation       0x023dc1a1 CFRunLoopRunInMode + 97
        21  GraphicsServices     0x029232c8 GSEventRunModal + 217
        22  GraphicsServices     0x0292338d GSEventRun + 115
        23  UIKit                0x00131b58 UIApplicationMain + 1160
        24  FaceConnect          0x00001ac9 main + 121
        25  FaceConnect          0x00001a45 start + 53
        26  ???                  0x00000001 0x0 + 1 )
2011-08-12 11:42:02.346 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x7e06a40 of class NSCFString autoreleased with no pool in place - just leaking
2011-08-12 11:42:02.346 FaceConnect[1651:6b07] *** __NSAutoreleaseNoPool(): Object 0x6f4c0c0 of class NSCFString autoreleased with no pool in place - just leaking terminate called after throwing an instance of 'NSException' Current language:  auto; currently objective-c

I have just checked it on my iPhone, and the application does not crash. It only happens on the simulator.


-(IBAction)login:(id)sender {

  [(UIButton*) sender setEnabled:NO];   

  if([[NSFileManager defaultManager] fileExistsAtPath:filePath])  {
   NSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath];

   NSString* name = [array objectAtIndex:0];
   NSString* contactId = [array objectAtIndex:1]; // depends if it is an integer then use int
   NSString* gender = [array objectAtIndex:2];
   NSString* contactType = [array objectAtIndex:3];

   //[self.userArray removeAllObjects]; // what is your user array and why you are removing all the objects
                                   // i could not find where you are setting the value for userArray
   [self.userArray arrayWithObjects:self.name, self.contactId, self.gender,self.contactType, nil];

   [self performSelectorInBackground:@selector(sendData) withObject:nil];

   /*if (loginButton.selected == NO) {
    // Represents user needs to login. Code for login user.
  }else
  {
     [loginButton setTitle:@"Logout"]; 
  }

  // toggle the login/logout states.
  loginButton.selected = !loginButton.selected;*/

  UIBarButtonItem *logoutButton = [[UIBarButtonItem alloc] initWithTitle:@"Logout"  style:UIBarButtonItemStylePlain target:self action:@selector(logout:)];

  //[logoutButton setTitle:@"Logout"];  
  [[self navigationItem] setRightBarButtonItem:logoutButton];
  [logoutButton release];
 }

 else {
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New User" message:@"It seems you have not used FaceDirectory before, please go to My Details and fill out the information then click save." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];

   [alert show];
   [alert release];

}
[(UIButton*) sender setEnabled:YES];

}

i could not find where you are setting the value for userArray and so i thought i think you are binding the info to userArray and sending

-(id)sendData{
  //Do whatever you want to do with userArray
}


 -(void)viewDidUnLoad{
      self.userarray = nil;
      [super viewDidlUnload];
 }
 -(void)dealloc{
     [userArray release];
     [super dealloc];
  }


You create an empty strings with alloc/init, and then you change them to value returned by objectAtIndex:. This causes the pointer to point to an autoreleased value. After you release your strings, the application will crash because retain count will become less than zero.


I guess the error is propagating from FaceConnect. Please check, it's showing a lot of leaks and warnings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜