-2

我在运行以下代码时遇到异常,代码是

NSMutableArray *mutablearray = [NSMutableArray array];

    data=[MyDatabase new];
     imagearray=[data OpenMyDatabase:@"SELECT pic_name FROM interior":@"pic_name"];

    while([imagearray next])  /////Getting exception here
    {
       [mutablearray addObject:imagearray];
    }

我的例外是,

-[__NSArrayM next]:无法识别的选择器发送到实例背后的确切原因是什么?

4

3 回答 3

1

您没有正确枚举。

NSArray 文档中的示例:

NSEnumerator *enumerator = [myArray objectEnumerator];
id anObject;

while (anObject = [enumerator nextObject]) {
    /* code to act on each element as it is returned */
}
于 2013-03-13T07:47:20.047 回答
1

尝试

[mutablearray addObjectsFromarray:imagearray];

代替

while([imagearray next])  
{
   [mutablearray addObject:imagearray];
}
于 2013-03-13T07:49:04.137 回答
1

试试这个

 NSMutableArray *mutablearray = [NSMutableArray array];

 data=[MyDatabase new];
 imagearray=[data OpenMyDatabase:@"SELECT pic_name FROM interior":@"pic_name"];

 NSEnumerator *e = [imagearray objectEnumerator];
 id object;
 while (object = [e nextObject]) {
    [mutablearray addObject:object];

 }
于 2013-03-13T07:49:19.563 回答