2013-05-09 3 views
0

모두입니다. NSTableView를 사용하면이 함수에 도달하는 한 다음 오류가 발생합니다.NSTableView 오류 - [__ NSCFConstantString setFrame :]

-(id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ 

USBInfor* usbInfor = [_tableContent objectAtIndex:row]; 
NSString* identifier = [tableColumn identifier]; 

return [usbInfor valueForKey:identifier]; 
} 

USB의 이름, 크기, 경로 및 유형을 저장하기 위해 usbInfor 클래스를 만들었습니다. 그리고 이러한 변수를 _tableContent NSMutableArray에 추가합니다.

USBInfor *usbinfor = [[USBInfor alloc]init]; 
usbinfor.name = [mountPath substringFromIndex:9]; 
usbinfor.path = mountPath; 
usbinfor.size = formattingSize; 
usbinfor.type = type; 

[_tableContent addObject:usbinfor]; 

난 XIB 파일 3 열을 생성하고, 식별자 각각은 I 이름, 경로 및 크기 변수의 이름과 동일한 이름.

는 여기에 오류가 있습니다 :

그것은 OS X 10.5 및 기본 SDK의 OS X 10.7

감사에서 실행하는

2013-05-08 22:56:34.157 TESTING[7760:303] -[__NSCFString setFrame:]: unrecognized  selector sent to instance 0x10022a3d0 
2013-05-08 22:56:34.158 TESTING[7760:303] An uncaught exception was raised 
2013-05-08 22:56:34.159 TESTING[7760:303] -[__NSCFString setFrame:]: unrecognized selector sent to instance 0x10022a3d0 
2013-05-08 22:56:34.162 TESTING[7760:303] (
0 CoreFoundation      0x00007fff81e8ab06 __exceptionPreprocess + 198 
1 libobjc.A.dylib      0x00007fff81a003f0 objc_exception_throw + 43 
2 CoreFoundation      0x00007fff81f2140a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186 
3 CoreFoundation      0x00007fff81e7902e ___forwarding___ + 414 
4 CoreFoundation      0x00007fff81e78e18 _CF_forwarding_prep_0 + 232 
5 AppKit        0x00007fff8c456a73 -[NSTableRowData _addViewToRowView:atColumn:row:] + 533 
6 AppKit        0x00007fff8c45666f -[NSTableRowData _addViewsToRowView:atRow:] + 151 
7 AppKit        0x00007fff8c454c05 -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 415 
8 AppKit        0x00007fff8c45498a -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 272 
9 AppKit        0x00007fff8c453c59 -[NSTableRowData _unsafeUpdateVisibleRowEntries] + 740 
10 AppKit        0x00007fff8c4537f1 -[NSTableRowData updateVisibleRowViews] + 119 
11 AppKit        0x00007fff8c42b87b -[NSTableView viewWillDraw] + 165 
12 AppKit        0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307 
13 CoreFoundation      0x00007fff81e834a6 __NSArrayEnumerate + 582 
14 AppKit        0x00007fff8c308f2d -[NSView viewWillDraw] + 244 
15 AppKit        0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307 
16 CoreFoundation      0x00007fff81e834a6 __NSArrayEnumerate + 582 
17 AppKit        0x00007fff8c308f2d -[NSView viewWillDraw] + 244 
18 AppKit        0x00007fff8c393aa5 -[NSScrollView viewWillDraw] + 45 
19 AppKit        0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307 
20 CoreFoundation      0x00007fff81e834a6 __NSArrayEnumerate + 582 
21 AppKit        0x00007fff8c308f2d -[NSView viewWillDraw] + 244 
22 AppKit        0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307 
23 CoreFoundation      0x00007fff81e834a6 __NSArrayEnumerate + 582 
24 AppKit        0x00007fff8c308f2d -[NSView viewWillDraw] + 244 
25 AppKit        0x00007fff8c308584 -[NSView _sendViewWillDrawInRect:clipRootView:] + 1525 
26 AppKit        0x00007fff8c2d49b1 -[NSView displayIfNeeded] + 1044 
27 AppKit        0x00007fff8c391a48 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1377 
28 AppKit        0x00007fff8c391068 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 940 
29 AppKit        0x00007fff8c390c4f -[NSWindow orderWindow:relativeTo:] + 159 
30 AppKit        0x00007fff8c292266 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1424 
31 AppKit        0x00007fff8c27114d loadNib + 317 
32 AppKit        0x00007fff8c270679 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 219 
33 AppKit        0x00007fff8c3c35bc +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 140 
34 AppKit        0x00007fff8c270398 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 626 
35 AppKit        0x00007fff8c26ca2f NSApplicationMain + 398 
36 TESTING        0x00000001000012b2 main + 34 
37 TESTING        0x0000000100001264 start + 52 
) 
2013-05-08 22:56:34.164 TESTING[7760:303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString setFrame:]: unrecognized selector sent to instance 0x10022a3d0' 
*** First throw call stack: 
(
0 CoreFoundation      0x00007fff81e8ab06 __exceptionPreprocess + 198 
1 libobjc.A.dylib      0x00007fff81a003f0 objc_exception_throw + 43 
2 CoreFoundation      0x00007fff81f2140a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186 
3 CoreFoundation      0x00007fff81e7902e ___forwarding___ + 414 
4 CoreFoundation      0x00007fff81e78e18 _CF_forwarding_prep_0 + 232 
5 AppKit        0x00007fff8c456a73 -[NSTableRowData _addViewToRowView:atColumn:row:] + 533 
6 AppKit        0x00007fff8c45666f -[NSTableRowData _addViewsToRowView:atRow:] + 151 
7 AppKit        0x00007fff8c454c05 -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 415 
8 AppKit        0x00007fff8c45498a -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 272 
9 AppKit        0x00007fff8c453c59 -[NSTableRowData _unsafeUpdateVisibleRowEntries] + 740 
10 AppKit        0x00007fff8c4537f1 -[NSTableRowData updateVisibleRowViews] + 119 
11 AppKit        0x00007fff8c42b87b -[NSTableView viewWillDraw] + 165 
12 AppKit        0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307 
13 CoreFoundation      0x00007fff81e834a6 __NSArrayEnumerate + 582 
14 AppKit        0x00007fff8c308f2d -[NSView viewWillDraw] + 244 
15 AppKit        0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307 
16 CoreFoundation      0x00007fff81e834a6 __NSArrayEnumerate + 582 
17 AppKit        0x00007fff8c308f2d -[NSView viewWillDraw] + 244 
18 AppKit        0x00007fff8c393aa5 -[NSScrollView viewWillDraw] + 45 
19 AppKit        0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307 
20 CoreFoundation      0x00007fff81e834a6 __NSArrayEnumerate + 582 
21 AppKit        0x00007fff8c308f2d -[NSView viewWillDraw] + 244 
22 AppKit        0x00007fff8c3091ed __22-[NSView viewWillDraw]_block_invoke_0 + 307 
23 CoreFoundation      0x00007fff81e834a6 __NSArrayEnumerate + 582 
24 AppKit        0x00007fff8c308f2d -[NSView viewWillDraw] + 244 
25 AppKit        0x00007fff8c308584 -[NSView _sendViewWillDrawInRect:clipRootView:] + 1525 
26 AppKit        0x00007fff8c2d49b1 -[NSView displayIfNeeded] + 1044 
27 AppKit        0x00007fff8c391a48 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1377 
28 AppKit        0x00007fff8c391068 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 940 
29 AppKit        0x00007fff8c390c4f -[NSWindow orderWindow:relativeTo:] + 159 
30 AppKit        0x00007fff8c292266 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1424 
31 AppKit        0x00007fff8c27114d loadNib + 317 
32 AppKit        0x00007fff8c270679 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 219 
33 AppKit        0x00007fff8c3c35bc +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 140 
34 AppKit        0x00007fff8c270398 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 626 
35 AppKit        0x00007fff8c26ca2f NSApplicationMain + 398 
36 TESTING        0x00000001000012b2 main + 34 
37 TESTING        0x0000000100001264 start + 52 
) 
libc++abi.dylib: terminate called throwing an exception 

!

+0

"OS X 10.5에서 실행해야합니다."그런 다음보기 기반 테이블보기를 사용하면 안됩니다. 그것들은 라이온 (10.7)에서 소개되었습니다. Leopard (10.5) 또는 Snow Leopard (10.6)에서는 작동하지 않습니다. –

답변

3

메서드, tableView : viewForTableColumn : row :는 NSView 또는 NSView의 하위 클래스를 반환해야합니다. [usbInfor valueForKey : identifier]는 identifier가 "name"인 문자열 ([mountPath substringFromIndex : 9])을 반환합니다. 네가 뭘하려고하는지 모르지만 분명히 틀렸어.

+0

감사합니다 !!! :) :) :) –

0

[tableColumn identifier]는 열 이름을 식별하는 데 사용됩니다. 따라서 다음과 같아야합니다.

NSString *filename = [[itemArray1 objectAtIndex:rowIndex] objectForKey:key1a]; 
NSString *path = [[itemArray1 objectAtIndex:rowIndex] objectForKey:key1b]; 

NSString *identifier = [tableColumn identifier]; 
if ([identifier] isEqualToString:@"whatever a column name is"]) { 
    return filename; 
} 

else if ([identifier] isEqualToString:@"whatever a column name is"]) { 
    return path; 
} 

...