如何显示对象与NSLog的数组 [英] How to display an array of object with NSLog

查看:239
本文介绍了如何显示对象与NSLog的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是的NSLog显示对象的数组的解决方案。

what is the solution to display an array of object with "NSLog".

我可以用我的TableView显示它:

I can display it with my TableView with :

- (UITableViewCell *)tableView:(UITableView *)tableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UITableViewCell *cell = [tableView
                                 dequeueReusableCellWithIdentifier:@"MyBasicCell2"];
        DataOrder *bug = [[[ArrayBuying instance] tableau] objectAtIndex:indexPath.row];
      static NSString *CellIdentifier = @"MyBasicCell2";
        CustomCellFinalView *Cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


        if (!Cell) {
            Cell = [[CustomCellFinalView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }

        Cell.NomProduit.text = bug.product;
        Cell.Quantite.text = [NSString stringWithFormat:@"%.2f €", bug.price];
        Cell.Prix.text = [NSString stringWithFormat:@"X %d  ", bug.quantite];

        return Cell;
        return cell;    
}

当我尝试在我的 viewDidLoad中:该方法

NSLog(@"%@",[[ArrayBuying instance] tableau]);

我得到我的目标输出:

I obtain in my target output:

(
    "<DataOrder: 0x15d5d980>",
    "<DataOrder: 0x15de1aa0>"
)

非常感谢你为你的未来的危机帮助

Thank you very much for your futur help

推荐答案

试试这个

for ( DataOrder *bug in [[ArrayBuying instance] tableau] ) 
{
    NSLog(@"Product:- %@ Price:-%@", bug.product, bug.price);
}

这篇关于如何显示对象与NSLog的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆