2010-10-05 4 views
2

Donc, je débogue une application que je construis et utilise la méthode de description pour m'aider à trouver le problème. Mais au lieu de me donner l'application comme une chaîne, elle imprime des parenthèses à la place. S'il vous plaît aider!Méthode 'description' de NSObject donnant des parenthèses en sortie?

Voici le code:

- (void)viewDidLoad { 
[super viewDidLoad]; 

reminders = [[NSMutableArray alloc] init]; 
currentTitle = [[NSMutableString alloc] init]; 
currentDate = [[NSMutableString alloc] init]; 
currentSummary = [[ 
       NSMutableString alloc] init]; 
currentLink = [[NSMutableString alloc] init]; 

NSLog(@"IT'S HERE %@", [reminders description]);} 

...

et l'erreur:

[Session started at 2010-10-04 22:15:16 -0400.] 
2010-10-04 22:15:17.434 Reminders[5824:207] ******* Accessibility Status Changed: On 
2010-10-04 22:15:17.464 Reminders[5824:207] ********** Loading AX for: com.yourcompany.Reminders ************ 
2010-10-04 22:15:17.506 Reminders[5824:207] IT'S HERE (
) 
2010-10-04 22:15:17.510 Reminders[5824:207] Hello 
2010-10-04 22:15:17.512 Reminders[5824:207] (
) 
2010-10-04 22:15:17.514 Reminders[5824:207] PVC: <UITableView: 0x602d600; frame = (0 20; 320 460); clipsToBounds = YES; opaque = NO; autoresize = W+H; layer = <CALayer: 0x5f3f3b0>; contentOffset: {0, 0}> 
2010-10-04 22:15:17.514 Reminders[5824:207] It's here 
2010-10-04 22:15:17.515 Reminders[5824:207] Loaded 
2010-10-04 22:15:17.520 Reminders[5824:207] -[__NSCFArray name]: unrecognized selector sent to instance 0x6a4b640 
2010-10-04 22:15:17.523 Reminders[5824:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray name]: unrecognized selector sent to instance 0x6a4b640' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x0248bb99 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x025db40e objc_exception_throw + 47 
    2 CoreFoundation      0x0248d6ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x023fd2b6 ___forwarding___ + 966 
    4 CoreFoundation      0x023fce72 _CF_forwarding_prep_0 + 50 
    5 Reminders       0x00003aa9 -[RootViewController tableView:cellForRowAtIndexPath:] + 300 
    6 UIKit        0x00090d6f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 619 
    7 UIKit        0x00086e02 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75 
    8 UIKit        0x0009b774 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561 
    9 UIKit        0x000937ec -[UITableView layoutSubviews] + 242 
    10 QuartzCore       0x03f60481 -[CALayer layoutSublayers] + 177 
    11 QuartzCore       0x03f601b1 CALayerLayoutIfNeeded + 220 
    12 QuartzCore       0x03f592e0 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 302 
    13 QuartzCore       0x03f59040 _ZN2CA11Transaction6commitEv + 292 
    14 UIKit        0x0002204e -[UIApplication _reportAppLaunchFinished] + 39 
    15 UIKit        0x00022477 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 545 
    16 UIKit        0x0002c3ec -[UIApplication handleEvent:withNewEvent:] + 1958 
    17 UIKit        0x00024b3c -[UIApplication sendEvent:] + 71 
    18 UIKit        0x000299bf _UIApplicationHandleEvent + 7672 
    19 GraphicsServices     0x026fa822 PurpleEventCallback + 1550 
    20 CoreFoundation      0x0246cff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    21 CoreFoundation      0x023cd807 __CFRunLoopDoSource1 + 215 
    22 CoreFoundation      0x023caa93 __CFRunLoopRun + 979 
    23 CoreFoundation      0x023ca350 CFRunLoopRunSpecific + 208 
    24 CoreFoundation      0x023ca271 CFRunLoopRunInMode + 97 
    25 UIKit        0x00021c6d -[UIApplication _run] + 625 
    26 UIKit        0x0002daf2 UIApplicationMain + 1160 
    27 Reminders       0x00002078 main + 102 
    28 Reminders       0x00002009 start + 53 
) 
terminate called after throwing an instance of 'NSException' 

est ici la méthode que vous avez demandé Fluchtpunkt

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"cell"; 

    cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    // Configure the cell. 

    Reminder *theReminder = [reminders objectAtIndex:indexPath.row]; 

    cell.textLabel.text = theReminder.name; 

    return cell; 

    } 
+0

s'il vous plaît ajouter 'NSLog (@ "% @", rappels)' avant 'Rappel * theReminder = [rappels objectAtIndex : indexPath.row]; 'Je pense qu'il y a plus de NSArrays dans le tableau reminders –

Répondre

1

ces parenthèses sont les o j'attendrais si je NSLog un tableau vide.
Ceci est absolument correct.


l'exception est soulevée parce que vous essayez d'appeler une méthode name sur un tableau NS (Mutable). Et les tableaux ne répondent pas au nom.

Pour trouver la cause de cette exception poster le code de cette méthode dans votre RootViewController

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
Questions connexes