-1
NSMutableArray *quesArrayForPar0 = [[NSMutableArray alloc] initWithObjects: 

[[NSMutableArray alloc] initWithObjects:@"We have a clearly stated vision for the next 5 years.", "-1", nil], 

[[NSMutableArray alloc] initWithObjects:@"Our organization has clearly established strategy to achieve the vision.", "-1", nil], 

[[NSMutableArray alloc] initWithObjects:@"This strategy is implemented uniformly and effectively throughout our organization.", "-1", nil], 

[[NSMutableArray alloc] initWithObjects:@"We are progressing as per our plan to realize this vision within the envisage time horizon.", "-1", nil] 

, nil]; 

위의 코드가 예외를 던지고있는 이유는 무엇입니까?다음 코드의 EXC_BAD_ACCESS 예외

+3

', "-1"은 정말로 코드에 있습니까? – Wain

+0

Ohh .. "-1"앞에 @를 넣는 것을 잊어 버렸습니다 .. 아주 어리석은 실수 .. – Shradha

+0

[XCode에서 EXC \ _BAD \ _ACCESS에서 중단할까요?] (http://stackoverflow.com/questions/1622079/) xcode에서 악의적 인 액세스) – Neeku

답변

3

내부 가변 배열에서 두 개의 다른 객체를 할당했기 때문에. 하나는 Obj-C 문자열 @""이고 다른 C 문자열은 ""입니다.

그래서 코드와 작동이 변경되었습니다.

NSMutableArray *quesArrayForPar0 = [[NSMutableArray alloc] initWithObjects: 
            [[NSMutableArray alloc] initWithObjects:@"We have a clearly stated vision for the next 5 years.", @"-1", nil], 
            [[NSMutableArray alloc] initWithObjects:@"Our organization has clearly established strategy to achieve the vision.", @"-1", nil], 
            [[NSMutableArray alloc] initWithObjects:@"This strategy is implemented uniformly and effectively throughout our organization.", @"-1", nil], 
            [[NSMutableArray alloc] initWithObjects:@"We are progressing as per our plan to realize this vision within the envisage time horizon.", @"-1", nil] 
            , nil]; 
+0

하나는 Obj-C 문자열이고 다른 하나는 C 문자열입니다. – Wain

+0

@Wain Thanks dude. 내 대답에 이것을 편집했습니다. –