从同一个类的另一个方法中检索一个NSMutableArray

时间:2012-07-13 06:31:58

标签: iphone

我是iphone的新手,我有一个小疑问,就是我在下面的课程中有一个方法

-(void)bookNamesWhichAreInDownloadedQueue:(NSMutableArray *)receivedBookNamesWhichAreInDownloadedQueue{
    NSLog(@"receivedBookNamesWhichAreInDownloadedQueue is %@",receivedBookNamesWhichAreInDownloadedQueue);
    bookNamesWhichAreInDownloadedQueue = receivedBookNamesWhichAreInDownloadedQueue;
    NSLog(@"bookNamesWhichAreInDownloadedQueue is %@",bookNamesWhichAreInDownloadedQueue);
}

这里bookNamesWhichAreInDownloadedQueue是一个NSMutableArray,它包含一些数据。我想用同一个类中的另一个方法检索这个数据的方式是怎么回事。如果有人知道这个请帮帮我

1 个答案:

答案 0 :(得分:2)

创建一个返回NSMutableArray

的方法
-(NSMutableArray*)bookNamesWhichAreInDownloadedQueue:(NSMutableArray *)receivedBookNamesWhichAreInDownloadedQueue{
    NSLog(@"receivedBookNamesWhichAreInDownloadedQueue is %@",receivedBookNamesWhichAreInDownloadedQueue);
    bookNamesWhichAreInDownloadedQueue = [[NSMutableArray alloc] initWithArray:receivedBookNamesWhichAreInDownloadedQueue];
    NSLog(@"bookNamesWhichAreInDownloadedQueue is %@",bookNamesWhichAreInDownloadedQueue);
    return bookNamesWhichAreInDownloadedQueue;
}

现在,您可以从要重试NSMutableArray !!

的方法中调用此方法

一切顺利!!!