- вы используете nsmutableurlrequest для генерации запроса веб-сервисов
- используйте nsuserdefaults для сохранения имени пользователя и пароля
Вот пример первого:
-(void)sendUpdate {
User *user = [User sharedManager];
NSData *parkedLocation = [[NSString stringWithFormat:@"<location><latitude>%f</latitude><longitude>%f</longitude><userid>%@</userid><udid>%@</udid></location>",
coordinate.latitude, coordinate.longitude, userid, user.udid] dataUsingEncoding:NSASCIIStringEncoding];
//NSLog("parkedlocation = %@", parkedLocation);
NSString *URLstr = LOCATIONS_URL;
if (controller.put_url)
URLstr = controller.put_url;
NSURL *theURL = [NSURL URLWithString:URLstr];
//NSURLRequest *theRequest = [NSURLRequest requestWithURL:theURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];
NSLog(@"IN SEND UPDATE put_url = %@", controller.put_url);
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];
if (controller.put_url) {
[theRequest setHTTPMethod:@"PUT"];
} else {
[theRequest setHTTPMethod:@"POST"];
}
[theRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];
[theRequest setHTTPBody:parkedLocation];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:TRUE];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (!theConnection) {
NSLog(@"COuldn't get a connection to the iParkNow! server");
}
}
и пример второй:
[[NSUserDefaults standardUserDefaults] setObject:self.userName.text forKey:@"Username"];
[[NSUserDefaults standardUserDefaults] setObject:self.password.text forKey:@"Password"];