HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了uitableview – 将NSMutablearray值加载到表视图中时出现问题?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 iphone开发的新手,我正在尝试将NSMutableArray值加载到表视图中,我正在使用下面的代码生成指定的错误.有人可以帮我纠正这个错误.

代码: –

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [ShowList count];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath 
{

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reusEIDentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    NSString *cellValue = [ShowList objectATindex:indexPath.row];
    cell.textLabel.text = cellValue;   
    return cell;

}

错误: –

2011-02-25 07:22:24.470 iPhone[1032:207] -[__NSArraym isEqualToString:]: unrecognized SELEctor sent to instance 0xab15d30
2011-02-25 07:22:24.471 iPhone[1032:207] *** TerminaTing app due to uncaught exception 'NSInvalidArgumentexception',reason: '-[__NSArraym isEqualToString:]: unrecognized SELEctor sent to instance 0xab15d30'
*** Call stack at first throw:

打印我的NSMutableArray的描述: –

2011-02-25 07:21:54.806[1032:207] (
        (
        "viral_tweeter",default1571546,default1570056,twilightsaga,"wp-monetizer",viraltweetbuild,"building_a_list",yourtwittertips,"twitter_profit",mikesbi,mikesbizz,default1164341,incbizztest,default1164319,iprotv,iwantafreecopy1,tweeterbuilder,trafficlists,myadsensenews,mysafelistnews,myviralnews,safelistology,slmembers,slpmembers,twonderlandlist,no@L_262_8@spider,y@L_262_8@spider,digitallockdown,alistblueprint,classifiedtips,incbizzblog,"xit-trafficbeta",twwidget,jvtrafficfunnel,instantmlmspage,listbuldingmax,"incbizz_tips"
    )
)

用于解析http代码获取响应: –

- (void)requestDataFetcher:(GTMhttpFetcher *)fetcher finishedWithData:(NSData *)data error:(NSError *)error {

    // this is only for tesTing whether the data is coming or not
    // NSDictionary *tempDict = [GTMOAuthAuthentication DictionaryWithResponseData:data];

    if (error) 
    {
        NSLog(@"Error: in getTing data after authentication : %@",[error description]);
    } 

    else 
    {
        // NSLog(@"Succcess: in getTing data after authentication \n data: %@",[tempDict description]);
        NSString* aStr;
        aStr = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
        NSDictionary *Dictionary = [aStr JSONValue];
        NSArray *keys = [Dictionary allKeys];
        Names = [[NSMutableArray alloc]init];
        int i = 0;
        // values in foreach loop
        for (NSString *key in keys) 
        {
            i++;
            NSArray *items = (NSArray *) [Dictionary objectForKey:key];  
            // NSLog(@" test %@",items);
            if (i==3) 
            {
                for (NSString *item in items) 
                { 
                    NSString* aStrs=  item;
                    // NSLog(@" test %@",aStrs);

                    NSDictionary *Dict = aStrs;
                    NSArray *k = [Dict allKeys];
                    for (id *it in k) 
                    {  
                        // NSLog(@"the  child item: %@",[NSString StringWithFormat:@"Child Item -> %@ value %@",(NSDictionary *) it,[Dict objectForKey:it]]);  
                        NSString *value = [it description]; 
                        if ( [value isEqualToString:@"name"]) 
                        {
                            NSString * value = (NSString*)[[Dict objectForKey:it] description];
                            NSLog(value);
                            [Names addObject:value];
                            [[MySingletonClass sharedMySingleton] SetaweberList: value];
                        }
                    }
                }
            }
        }


        mShowList.hidden = falSE;
    }

}

解决方法

@Ravi你的数组是数组的数组,ShowList是一个数组,它有第一个对象作为数组,那个数组是那个

"viral_tweeter","incbizz_tips"

所以你可以做这样的事情.

NSString *cellValue = [[ShowList objectATindex:0] objectATindex:indexPath.row];

大佬总结

以上是大佬教程为你收集整理的uitableview – 将NSMutablearray值加载到表视图中时出现问题?全部内容,希望文章能够帮你解决uitableview – 将NSMutablearray值加载到表视图中时出现问题?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。