Iphone 如何理解web服务应答中的字符串或数组
我从web服务获取数组值。此数组是1个或多个1元素数组。如果tempArra是一维数组,然后如果我想将数组中的数据传输到另一个数组(garbageDatesFor01),则会得到错误Iphone 如何理解web服务应答中的字符串或数组,iphone,objective-c,ios,nsarray,Iphone,Objective C,Ios,Nsarray,我从web服务获取数组值。此数组是1个或多个1元素数组。如果tempArra是一维数组,然后如果我想将数组中的数据传输到另一个数组(garbageDatesFor01),则会得到错误 EDIT: returning to the web service responses in 2 ways RESPONSE 1 ( ( "2011-08-03", "2011-08-17" ) ) OR RESPONSE 2 2011-08-04 NSArray *ga
EDIT: returning to the web service responses in 2 ways
RESPONSE 1
(
(
"2011-08-03",
"2011-08-17"
)
)
OR
RESPONSE 2
2011-08-04
NSArray *garbageDatesFor01=[[NSArray alloc] initWithArray:tempArr];
2011-08-26 18:43:35.689 AOK[1846:207] -[NSCFString count]: unrecognized selector sent to instance 0x990d8f0
2011-08-26 18:43:35.691 AOK[1846:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString count]: unrecognized selector sent to instance 0x990d8f0'
*** Call stack at first throw:
(
0 CoreFoundation 0x015d25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01726313 objc_exception_throw + 44
2 CoreFoundation 0x015d40bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01543966 ___forwarding___ + 966
4 CoreFoundation 0x01543522 _CF_forwarding_prep_0 + 50
5 CoreFoundation 0x01535d87 -[NSArray initWithArray:] + 39
6 TwenteMilieu 0x0001323a -[ForgottenContainerT1 connectionDidFinishLoading:] + 3750
7 Foundation 0x00113112 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
8 Foundation 0x0011306b _NSURLConnectionDidFinishLoading + 133
9 CFNetwork 0x0117148e _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220
10 CFNetwork 0x0123c6e1 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293
11 CFNetwork 0x01167c80 _ZN19URLConnectionClient13processEventsEv + 100
12 CFNetwork 0x01167acf _ZN17MultiplexerSource7performEv + 251
13 CoreFoundation 0x015b38ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
14 CoreFoundation 0x0151188b __CFRunLoopDoSources0 + 571
15 CoreFoundation 0x01510d86 __CFRunLoopRun + 470
16 CoreFoundation 0x01510840 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x01510761 CFRunLoopRunInMode + 97
18 GraphicsServices 0x01b411c4 GSEventRunModal + 217
19 GraphicsServices 0x01b41289 GSEventRun + 115
20 UIKit 0x0037fc93 UIApplicationMain + 1160
21 TwenteMilieu 0x00002644 main + 102
22 TwenteMilieu 0x000025d5 start + 53
)
terminate called after throwing an instance of 'NSException'
Current language: auto; currently objective-c
重要的一点是:
2011-08-26 18:43:35.689 TwenteMilieu[1846:207] -[NSCFString count]: unrecognized selector sent to instance 0x990d8f0
这意味着您正在对字符串调用count
。您认为是数组的对象实际上是字符串
通过查看代码,tempArr
可以是数组或字符串。试试这个:
if ([tempArr isKindOfClass:[NSArray class]])
{
// Handle array case
}
else if ([tempArr isKindOfClass:[NSString class]])
{
// Handle string case
}
将
tempArr
的名称改为其他名称可能是个好主意,例如tempResponse
或类似名称。重要的一行是:
2011-08-26 18:43:35.689 TwenteMilieu[1846:207] -[NSCFString count]: unrecognized selector sent to instance 0x990d8f0
这意味着您正在对字符串调用count
。您认为是数组的对象实际上是字符串
通过查看代码,tempArr
可以是数组或字符串。试试这个:
if ([tempArr isKindOfClass:[NSArray class]])
{
// Handle array case
}
else if ([tempArr isKindOfClass:[NSString class]])
{
// Handle string case
}
将
tempArr
的名称改为其他名称可能是个好主意,如tempResponse
或类似名称。我更新为问题。我并没有为这个问题的解决帮梅更新到问题。我不知道这个问题的解决方法对我有什么帮助