2012-05-08 4 views
1

사전 값의 배열에서 UItableview의 일부 값을로드하고 있습니다. I는NSdictionaries의 NSarray

NSMutableDictionary *rowDict = [tableList objectAtIndex:arrayindex]; 
[rowDict setObject:@"download successfull" forKey:@"downloadstatus"]; 

아래와 같은 하나 개 이상의 키 값 객체를 추가하여 배열 사전을 변경하지만,이 후 I는 충돌

NSMutableDictionary *rowDict = [tableList objectAtIndex:arrayindex]; 
NSString *SelectedState = (NSString*)[rowDict objectForKey:@"downloadstatus"]; 

아래로 배열 사전에서 값 retrieveing ​​때 .. . 하나는이

이 내 CONSOL에 충돌 표시입니다 해결하기 위해 나를 도울 수

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableData objectForKey:]: unrecognized selector sent to instance 0x61a8270' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x003b0be9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x015c15c2 objc_exception_throw + 47 
    2 CoreFoundation      0x003b26fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x00322366 ___forwarding___ + 966 
    4 CoreFoundation      0x00321f22 _CF_forwarding_prep_0 + 50 
    5 SifyMyStorage      0x0003b35b -[DownloadListViewController tableView:cellForRowAtIndexPath:] + 314 
    6 UIKit        0x00ec67fa -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634 
    7 UIKit        0x00ebc77f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75 
    8 UIKit        0x00ed1450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561 
    9 UIKit        0x00ec9538 -[UITableView layoutSubviews] + 242 
    10 QuartzCore       0x009f4451 -[CALayer layoutSublayers] + 181 
    11 QuartzCore       0x009f417c CALayerLayoutIfNeeded + 220 
    12 QuartzCore       0x009ed37c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310 
    13 QuartzCore       0x009ed0d0 _ZN2CA11Transaction6commitEv + 292 
    14 QuartzCore       0x00a1d7d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99 
    15 CoreFoundation      0x00391fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27 
    16 CoreFoundation      0x003270e7 __CFRunLoopDoObservers + 295 
    17 CoreFoundation      0x002efbd7 __CFRunLoopRun + 1575 
    18 CoreFoundation      0x002ef240 CFRunLoopRunSpecific + 208 
    19 CoreFoundation      0x002ef161 CFRunLoopRunInMode + 97 
    20 GraphicsServices     0x02ead268 GSEventRunModal + 217 
    21 GraphicsServices     0x02ead32d GSEventRun + 115 
    22 UIKit        0x00e6142e UIApplicationMain + 1160 
    23 SifyMyStorage      0x000020b8 main + 102 
    24 SifyMyStorage      0x00002049 start + 53 
) 
terminate called after throwing an instance of 'NSException' 
+0

이 콘솔의 출력을 게시 할 수 : 두 번째 코드 이것에 블록 나는 당신이 당신의 문제 (이러한 객체 == 0 중 하나에 retainCount를) 찾아 내기 할 것이다 - 변경

앱? –

+0

충돌 메시지 란 무엇입니까? 어떻게 arrayindex (arrayIndex라는 이름이어야 함)를 계산합니까? 대부분의 경우 색인이 범위를 벗어납니다. 또한 objectForKey 결과를 형변환 할 필요도 없습니다. – Joel

+0

stacktrace를 게시 할 수 있습니까? – trojanfoe

답변

0
See if you have allocated the object and also get the count of dictionary , if the value is being added also see if u have declared NSmutabledictionary or just NSdictionary ... a view at your class having the code would be more helpful to sort out your problem 
+0

나는 mutabledictionary만을 사용하고 있습니다. 배열 dll의 값을 가지고있는 tableList를 얻었습니다. – rashii

-2

NSMutableDictionary를 할당하지 않으면 NSMutableDictionary가 비어있어 앱이 다운됩니다.

NSMutableDictionary *rowDict = [[NSMutableDictionary alloc]init]; 

rowDict = [tableList objectAtIndex:arrayindex]; 
NSString *SelectedState = [rowDict objectForKey:@"downloadstatus"]; 

행운의 가장

+0

여전히 충돌이 없습니다. – rashii

0

좋아, 몇 가지 : 당신이 게시

년 - 코드는 괜찮습니다. 그건 문제가 아니야. (NSString *) 캐스트는 불필요하지만 문제는 아닙니다.

- NSArray 테이블 목록에 문제가 있습니다. 실제로 NSMutableDictionary를 배열에 추가하는 경우, 그 중 하나를 잘못하고 있거나 배열이 범위를 벗어났습니다. 배열에 액세스한다고 생각하면 그 위치의 메모리에서 다른 것을 액세스하고있는 것입니다.

컨트롤러에서 테이블 목록에 대한 참조를 어떻게 유지합니까? 당신이 충돌 할 때

NSLog(@"retain count=%d",[tableList retainCount]); 
NSMutableDictionary *rowDict = [tableList objectAtIndex:arrayindex]; 
NSLog(@"retain count=%d",[rowDict retainCount]); 
NSString *SelectedState = [rowDict objectForKey:@"downloadstatus"];