iOS目标C Web服务
有没有办法将我们的web服务委托方法保存在一个类中,并在需要时使用它们?通常情况下,我会在所有类中不断编写委托,例如iOS目标C Web服务,ios,objective-c,web-services,Ios,Objective C,Web Services,有没有办法将我们的web服务委托方法保存在一个类中,并在需要时使用它们?通常情况下,我会在所有类中不断编写委托,例如didReceiveResponse和didReceiveData等 有一种方法可以实现你想要实现的目标,但一定不要做得太过分。过多地使用单例通常被认为是不好的做法 制作一个可以在整个应用程序中使用的单例 在你的单身生活中:单身 如何使用: -(void)getImages{ NSMutableDictionary *params = [[NSMutableDictionary
didReceiveResponse
和didReceiveData
等 有一种方法可以实现你想要实现的目标,但一定不要做得太过分。过多地使用单例通常被认为是不好的做法
制作一个可以在整个应用程序中使用的单例
在你的单身生活中:单身
如何使用:
-(void)getImages{
NSMutableDictionary *params = [[NSMutableDictionary alloc]initWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",1],@"page",@"5",@"count", nil];
[[APISingleton sharedInstance] APIRequestWithParams:params onCompletion:^(id json) {
postsArray = [json objectForKey:@"posts"];
[self downloadImages];
} onFailure:^(AFHTTPRequestOperation *operation) {
//Do whatever you want if it does not work.
}];}
使用:有一种方法可以实现您想要实现的目标,但请确保不要过度。过多地使用单例通常被认为是不好的做法 制作一个可以在整个应用程序中使用的单例 在你的单身生活中:单身 如何使用:
-(void)getImages{
NSMutableDictionary *params = [[NSMutableDictionary alloc]initWithObjectsAndKeys:[NSString stringWithFormat:@"%ld",1],@"page",@"5",@"count", nil];
[[APISingleton sharedInstance] APIRequestWithParams:params onCompletion:^(id json) {
postsArray = [json objectForKey:@"posts"];
[self downloadImages];
} onFailure:^(AFHTTPRequestOperation *operation) {
//Do whatever you want if it does not work.
}];}
使用: