2011-10-03 3 views
1

J'essaye de faire un simple programme en cacao, un NSTabVew avec 2 items, dans le premier item je mets un contenu à une chaîne var, dans le second onglet j'affiche cette valeur. Je crée deux classes d'objets (Prima et Seconda), que j'ajouter 2 objet dans IB cadre comme Prima et SecondaValeur de passage entre NSTabView

Prima.m

- (IBAction) salva:(id) sender{ 
    nome = [field stringValue]; 
    NSLog(@"%@",nome); 
} 

Seconda.m

- (IBAction) visualizza:(id) sender{ 
    NSString *dato; 
    Prima *prima = [[Prima alloc] init]; 
    dato = prima.nome; 
    [label setStringValue:dato]; 
} 

quand je lance le programme j'obtiens cette erreur:

2011-10-03 11:42:43.511 Prova[44622:707] *** Assertion failure in -[NSTextFieldCell _objectValue:forString:errorDescription:], /SourceCache/AppKit/AppKit-1138/AppKit.subproj/NSCell.m:1564 
2011-10-03 11:42:43.511 Prova[44622:707] Invalid parameter not satisfying: aString != nil 
2011-10-03 11:42:43.513 Prova[44622:707] (
    0 CoreFoundation      0x00007fff8d497986 __exceptionPreprocess + 198 
    1 libobjc.A.dylib      0x00007fff90ed9d5e objc_exception_throw + 43 
    2 CoreFoundation      0x00007fff8d4977ba +[NSException raise:format:arguments:] + 106 
    3 Foundation       0x00007fff8cce914f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169 
    4 AppKit        0x00007fff88957685 -[NSCell _objectValue:forString:errorDescription:] + 160 
    5 AppKit        0x00007fff889575df -[NSCell _objectValue:forString:] + 19 
    6 AppKit        0x00007fff88957545 -[NSCell setStringValue:] + 41 
    7 AppKit        0x00007fff88a58039 -[NSControl setStringValue:] + 115 
    8 Prova        0x0000000100001365 -[Seconda visualizza:] + 133 
    9 CoreFoundation      0x00007fff8d48711d -[NSObject performSelector:withObject:] + 61 
    10 AppKit        0x00007fff88a3f852 -[NSApplication sendAction:to:from:] + 139 
    11 AppKit        0x00007fff88a3f784 -[NSControl sendAction:to:] + 88 
    12 AppKit        0x00007fff88a3f6af -[NSCell _sendActionFrom:] + 137 
    13 AppKit        0x00007fff88a3eb7a -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2014 
    14 AppKit        0x00007fff88abe57c -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 489 
    15 AppKit        0x00007fff88a3d786 -[NSControl mouseDown:] + 786 
    16 AppKit        0x00007fff88a0866e -[NSWindow sendEvent:] + 6280 
    17 AppKit        0x00007fff889a0f19 -[NSApplication sendEvent:] + 5665 
    18 AppKit        0x00007fff8893742b -[NSApplication run] + 548 
    19 AppKit        0x00007fff88bb552a NSApplicationMain + 867 
    20 Prova        0x0000000100000f92 main + 34 
    21 Prova        0x0000000100000f64 start + 52 
    22 ???         0x0000000000000001 0x0 + 1 
) 

où est l'erreur pour vous?

Répondre

1

Il semble que dato soit nul, ce qui est probablement dû au fait que les choses ne sont pas connectées directement dans le XIB. Sans plus d'informations je ne peux pas en dire plus.

+0

Ici, vous pouvez télécharger l'application, je pense que vous pouvez comprendre mieux que ce que je peux écrire: D www.allmyapp.net/wp-content/Prova.zip – kikko088

+0

probablement je comprends le problème .... est l'action, si j'init init mes classes avec des données, par exemple nome = @ "test" je peux voir ma var sur la classe Seconda. Comment puis-je passer une variable d'un champ de texte avec une action? – kikko088