gpt4 book ai didi

ios - 我的功能有什么问题

转载 作者:行者123 更新时间:2023-11-29 03:12:49 24 4
gpt4 key购买 nike

我正在从服务中获取数据,并像这样成功解析

-(NSMutableArray *)clubTypes
{
NSMutableArray *dataArray = [[NSMutableArray alloc] init];
NSString *url = [NSString stringWithFormat:@"%@category",KWSURLList];
NSLog(@"%@",url);
NSDictionary * returnDict = (NSDictionary *) [self callWebService:url];
if([returnDict objectForKey:@"result"])
{
// NSDictionary * returnDictResult = (NSDictionary *) [returnDict objectForKey:@"result"];
NSArray *returnedArray = [returnDict objectForKey:@"data"];

for(NSDictionary *clubDict in returnedArray)
{
ClubTypeDC *clubDC = [[ClubTypeDC alloc] init];
clubDC.clubTypeID = [[clubDict objectForKey:@"Id"] intValue];
clubDC.clubTypeTitle = [clubDict objectForKey:@"tittle"];
clubDC.clubTypeImage = [clubDict objectForKey:@"icons"];
[dataArray addObject:clubDC];
// NSLog(@"%@",proEvents.proEventImage);
}

}

}

但我总是在 numberOfRowsInSection 中收到错误访问错误。谁能告诉我为什么?

最佳答案

记住总是这样返回你的数组

返回数据数组;

我修改了你的代码,请检查

 -(NSMutableArray *)clubTypes
{
NSMutableArray *dataArray = [[NSMutableArray alloc] init];
NSString *url = [NSString stringWithFormat:@"%@category",KWSURLList];
NSLog(@"%@",url);
NSDictionary * returnDict = (NSDictionary *) [self callWebService:url];
if([returnDict objectForKey:@"result"])
{
// NSDictionary * returnDictResult = (NSDictionary *) [returnDict objectForKey:@"result"];
NSArray *returnedArray = [returnDict objectForKey:@"data"];

for(NSDictionary *clubDict in returnedArray)
{
ClubTypeDC *clubDC = [[ClubTypeDC alloc] init];
clubDC.clubTypeID = [[clubDict objectForKey:@"Id"] intValue];
clubDC.clubTypeTitle = [clubDict objectForKey:@"tittle"];
clubDC.clubTypeImage = [clubDict objectForKey:@"icons"];
[dataArray addObject:clubDC];
// NSLog(@"%@",proEvents.proEventImage);
}

}
return dataArray;
}

关于ios - 我的功能有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22039264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com