views:

15

answers:

1

I am wondering if theres a way to remotely write to a plist file stored on my server. The directory the file is located has write access, but i cannot seem to push the new data. Heres my code:

NSString *accountURL = [NSString stringWithFormat:@"http://www.mywebsite.com//%@.plist",txtUsername.text];
NSURL *url = [NSURL URLWithString:accountURL];
NSMutableDictionary *account = [[NSMutableDictionary alloc] initWithContentsOfURL:url];

    [account setObject:@"TEST" forKey:@"LastLogin"];
    if ([account writeToURL:url atomically:NO]){
        NSLog(@"saved");
    }else{
        NSLog(@"not saved");
    }

The plist file exists because I can read from it with no problem. I just cannot write to the file.

On another note, is this even AppStore-friendly if the accounts will be stored on my server?

+1  A: 

Read-only is easy. As soon as you get into writing something you get into permissions for: server, application, user.

To solve your problem you need to create a web service that will authenticate the user and application, check permissions and save the file. Typically it would be a server accepting a POST or PUT from your iPhone app (similar to what browsers do for upload)

Zepplock