试图将字符串拆分为数组,但它给出错误“[__NSArrayI componentsSeparatedByString:]: unrecognized selector sent to instance 0x11741b20'”。字符串包含值,该值来自数组的第一个索引,然后需要将字符串拆分并存储在数组中。
这是数组值。
mcommarr:(
":comment",
":comment",
":comment"
NSString *strr = [[NSString alloc]init];
strr = [self.mCommArr objectAtIndex:indexVal];
NSArray *arr2 = [str componentsSeparatedByString:@","];
这是我使用它的完整方法。
-(void)loadData:(int)indexVal;
{
indexVal=serialIndexVal;
serialIndexVal++;
NSLog(@"arrLike:%d", [self.mArrLike count]);
NSLog(@"arrPid:%d", [self.mArrPid count]);
status = [NSString stringWithFormat:@"get"];
[self.mButtonsStatusDict setObject:status forKey:@"status"];
[self.mButtonsPidDict setObject:[self.mArrPid objectAtIndex:indexVal] forKey:@"pid"];
[self.activityIndicator startAnimating];
@try
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
NSString *status = [NSString stringWithFormat:@"get"];
[self.mButtonsStatusDict setObject:status forKey:@"status"];
[self.mButtonsPidDict setObject:[self.mArrPid objectAtIndex:indexVal] forKey:@"pid"];
self.mButtonsCommentsDict = [MyEventApi showComments:self.mButtonsPidDict];
self.mButtonsDict = [MyEventApi likeDislike:self.mButtonsUidDict post:self.mButtonsPidDict postStatus:self.mButtonsStatusDict];
dispatch_sync(dispatch_get_main_queue(), ^{
[self.activityIndicator stopAnimating];
NSLog(@"buttons data dict:%@", self.mButtonsDict);
if([self.mButtonsDict count] == 0)
{
NSLog(@"server problem no response");
[self.mArrLike addObject: @"0"];
[self.mArrDislike addObject: @"0"];
}else{
[self.mArrLike addObject: [self.mButtonsDict valueForKey:@"like"]];
[self.mArrDislike addObject: [self.mButtonsDict valueForKey:@"dislike"]];
}
if([self.mButtonsCommentsDict count] == 0)
{
NSLog(@"server problem no response");
[self.mCommArrTot addObject: @"0"];
}
else{
self.dictComm = [self.mButtonsCommentsDict valueForKey:@"comments"];
[self.mCommArr addObject:[self.dictComm valueForKey:@"comment"]];
NSLog(@"count:%d",[self.mCommArr count]);
// NSString *strTot = [NSString stringWithFormat:@"%d",tot];
// [self.mCommArrTot addObject:strTot];
NSLog(@"dictcomm:%@", self.dictComm );
NSLog(@"mcommarr:%@", [self.mCommArr objectAtIndex:indexVal]);
strr = [[NSString alloc]init];
strr = [self.mCommArr objectAtIndex:indexVal];
//NSString *strr = [[NSString stringWithFormat:@"%@", [self.mCommArr objectAtIndex:indexVal]];
// NSArray *arr1 = [self string:strr];
// NSArray *splitArray=[self.mCommArr[0] componentsSeparatedByString:@","];
//[strr componentsSeparatedByString:@","];
// NSLog(@"arrSep:%@", arr1);
//int count = [arr1 count];
//NSLog(@"arrcount:%d", count);
// NSString *strTot = [NSString stringWithFormat:@"%d",count];
// [self.mCommArrTot addObject:strTot];
//NSLog(@"mcommarrtot:%@", [self.mCommArrTot objectAtIndex:indexVal]);
}
// NSLog(@"arrLike:%@", [self.mArrLike objectAtIndex:indexVal]);
// NSLog(@"arrDisLike:%@", [self.mArrLike objectAtIndex:indexVal]);
[self.mPublicFriendTable reloadData];
});
});
}
@catch (NSException *exception) {
NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
}
@finally {
}
}
它在尝试分裂时被杀死。为什么这样,我没有得到。如果有人遇到过这种情况,请指导她出了什么问题。