인터페이스 다음 감안할 때 :있는 NSDictionary 리터럴, 모든 값 방법에 예외
@interface DetailViewController()
@property (nonatomic, strong) NSDictionary *contentTypeToString;
@property (nonatomic, strong) NSDictionary *contentTypeToContent;
@property (nonatomic, strong) NSArray *contentDestcriptors;
@property (nonatomic, strong) NSArray *content;
@end
그리고 다음과 같은 방법
- (void)viewDidLoad
{
[super viewDidLoad];
//dumb data
self.contentTypeToString [email protected]{
[NSNumber numberWithInt:ContextTypePlace] : @"Place",
[NSNumber numberWithInt:ContextTypeDate] : @"Date",
[NSNumber numberWithInt:ContextTypeTime] : @"Time",
[NSNumber numberWithInt:ContextTypeWeather] : @"Weather",
[NSNumber numberWithInt:ContextTypeSeason] : @"Season",
[NSNumber numberWithInt:ContextTypeTimeOfDay] : @"Time of Day",
[NSNumber numberWithInt:ContextTypePlace] : @"Place",
};
self.contentTypeToContent = @{
[NSNumber numberWithInt:ContextTypePlace] : @"Dublin",
[NSNumber numberWithInt:ContextTypeDate] : @"21.12.2012",
[NSNumber numberWithInt:ContextTypeTime] : @"21:32",
[NSNumber numberWithInt:ContextTypeWeather] : @"Cloudy",
[NSNumber numberWithInt:ContextTypeSeason] : @"Winter",
[NSNumber numberWithInt:ContextTypeTimeOfDay] : @"Evening",
[NSNumber numberWithInt:ContextTypePerson] : @"John, Ann",
};
self.contentDestcriptors = [self.contentTypeToString allValues];
self.content = [self.contentTypeToContent allValues];
}
내가 얻을 : 응용 프로그램을 종료
인해 캐치되지 않는 예외 NSRangeException
이유에 : *** -[__NSArrayI objectAtIndex:]: index 6 beyond bounds [0 .. 5]
Tf 나는 e 어디에서 allValues metod를 사용하는지, 코드는 잘 동작합니다. 리터럴 버그, 또는 내 잘못? `: [ContextTypePlace의 NSNumber numberWithInt]
가 가다가 대신'의 ContextTypePlace' @'사용할 수있는 두 번 6 개 항목으로 사전을 만들 것
을ContextTypePlace
지정 –예외가 발생하면 스택 추적을 게시 할 수 있습니까? – joerick
실제 @ (enum-value)뿐만 아니라 @ enum-value – foFox