相关疑难解决方法(0)

从webservices url获取密码并通过该密码访问

我有一个附加了访问代码的Webservices URL.我需要将访问代码发布到webservices url并获取json响应.我正在使用正确的访问代码和错误的访问代码获得json响应.我没有得到问题所在.我需要在输入错误密码时显示警报,这是我的代码..

  NSString *post =[[NSString alloc] initWithFormat:@"txtsecurecode=%@",[txtsecurecode text]];
        NSLog(@"PostData: %@",post);
        NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
        NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
        NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];

      [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://my example.com/Accountservice/Security/ValidateAccess?accesscode=abcdtype=1"]]];

        NSURL *url;

  // I need to parse it into url here .  

        [request setHTTPMethod:@"POST"];
        [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
        [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        [request setHTTPBody:postData];
        NSURLConnection *conn= [[NSURLConnection alloc] initWithRequest:request delegate:self];
        if(conn)
        {
            NSLog(@"Connection Successful");
        }
        else
        {
            NSLog(@"Connection could not be made");
        }

    NSString *responseData = [[NSString …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa objective-c ios

2
推荐指数
1
解决办法
1390
查看次数

标签 统计

cocoa ×1

ios ×1

iphone ×1

objective-c ×1