पर कॉल करें, मैं एक चयनकर्ता को पैरामीटर के रूप में पास करने और इसे बाद में निष्पादित करने का प्रयास कर रहा हूं। लेकिन मैं एक SIGABRT त्रुटि मिलती है जब मैं कंसोल में अगले त्रुटि के साथ चयनकर्ता कॉल करने के लिए प्रयास करें:उद्देश्य-सी: पास पैरामीटर के रूप में चयनकर्ता और फिर इसे
समाप्त एप्लिकेशन न आया हुआ अपवाद 'NSInvalidArgumentException', कारण की वजह से: '- [HttpRequest OnFinishConn:]: गैर मान्यता प्राप्त चयनकर्ता उदाहरण 0x7834c80 '
HttpRequest.h
#import <Foundation/Foundation.h>
@interface HttpRequest : NSObject
{
@private SEL onEndSel;
@private NSMutableData* receivedData;
}
-(void) StartRequest:(NSString *) url
parameters:(NSString*) params
onEndSelector:(SEL) selector;
@end
HttpRequest.m
के लिए भेजा#import "HttpRequest.h"
@implementation HttpRequest
-(void) StartRequest:(NSString *)url
parameters:(NSString*)params
onEndSelector:(SEL)selector
{
receivedData = [[NSMutableData alloc] init];
NSMutableURLRequest *request =
[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
onEndSel = selector;
NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
-(void) connectionDidFinishLoading:(NSURLConnection*) connection
{
//NSLog([[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding]);
[self performSelector:onEndSel withObject:[[NSMutableData alloc] initWithData:receivedData]];
}
-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[receivedData appendData:data];
}
@end
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//self.window.backgroundColor = [UIColor whiteColor];
HttpRequest* req = [[HttpRequest alloc] init];
SEL mysel = @selector(OnFinishConn:);
NSString * url = [[NSString alloc] initWithString:@"http://www.google.es"];
[req StartRequest:url parameters:@"a" onEndSelector:@selector(OnFinishConn:)];
[self.window makeKeyAndVisible];
return YES;
}
-(void)OnFinishConn:(NSMutableData *)data
{
NSLog([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}
मैं उद्देश्य सी में नए हूँ, इसलिए कृपया धैर्य रखें।
हालांकि यह आपके प्रश्न का उत्तर नहीं दे रहा है, तथ्य यह है कि आप इस सवाल से पूछते हैं, मुझे सलाह है कि आप पहिया – Jonathan