Can anyone give me a simple sqlite example in Cocoa Mac? I want to use it in my Mac desktop application. I don't k开发者_StackOverflow中文版now how to use sqllite in a mac application.
FMDB is a Cocoa wrapper for SQLite that's pretty commonly used. See fmdb.m for some examples.
Passing strings to distant PHP file from Mac application. This is how you can do it.
// form text fields and values NSArray *formfields = [NSArray arrayWithObjects:@"email", @"password", @"confirm_password", nil]; NSArray *formvalues = [NSArray arrayWithObjects:[nameField stringValue], [passwordField stringValue],[confirmField stringValue], nil]; NSDictionary *textParams = [NSDictionary dictionaryWithObjects:formvalues forKeys:formfields]; // submit the form [self doPostWithText:textParams]; - (void) doPostWithText:(NSDictionary *)textParams { NSString *urlString = @"Your Remote PHP Url goes here!"; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSMutableData *body = [NSMutableData data]; NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; [request addValue:contentType forHTTPHeaderField:@"Content-Type"]; // add the text form fields for (id key in textParams) { [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; //[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:[textParams objectForKey:key]] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; } // close form [body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; // set request body [request setHTTPBody:body]; //return and test NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; NSLog(@"%@", returnString); }
精彩评论