Reputation: 177
I have a class here
@interface Utils : NSObject
+(NSString *)getURL1;
+(NSString *)getURL2;
+(NSString *)getURL3;
@end
@implementation Utils
+(NSString *)getURL1
{
return "url1";
}
+(NSString *)getURL2
{
return "url2";
}
+(NSString *)getURL3
{
return "url3";
}
@end
I need to read all methods of this class which returns 'url' as substring. Can I do that ?
Upvotes: 1
Views: 112
Reputation: 46563
need to read all methods of this class which returns 'url' as substring. Can i do that ?
NO, you can not do it straightforward.
There could be other methods as well which will be returning something else. Also you need to call all the methods by yourself. Else a bit of trick by using Obj-C runtime to call all the 500 methods that the class contains.
If you are damn sure you will be having only few methods then call each of them store the returned value in an array, and filter out values begining with "url".
Upvotes: 4
Reputation: 79
You just need to import this class in any of the class you want these methods to work in as follows:
#import "Utils.h"
Now as this is an NSObject
class, you just need to call the methods from that class as follows:
NSString * urlStringForYou = [Utils getURL1];
You are done. You will get the string in urlStringForYou
as you want.
Upvotes: 0