从同一个类的另一个方法中检索一个NSMutableArray [英] Retrieve an NSMutableArray which is in a method from another method of same class

查看:77
本文介绍了从同一个类的另一个方法中检索一个NSMutableArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iphone的新手,我有一个小小的疑问,就是我在类中的方法低于

I am new to iphone i have a small doubt that is I have a method in a class that is below

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

这里bookNamesWhichAreInDownloadedQueue是一个NSMutableArray,它包含一些数据。我想要检索这个数组在同一个类中的另一个方法中的数据如何可能。如果有人知道这个请帮帮我

here bookNamesWhichAreInDownloadedQueue is an NSMutableArray it contains some data in it.I want to retrieve this array with that data in another method in same class how it is possible.If anybody know this please help me

推荐答案

制作一个返回 NSMutableArray 的方法:

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

现在你可以从想要检索<的方法中调用此方法code> NSMutableArray !!

Now you can call this method from the method where you want to retrive the NSMutableArray!!

一切顺利!!!

这篇关于从同一个类的另一个方法中检索一个NSMutableArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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