Approach to develop an iPhone app to visit forum
Suppose I have an forum written in PHP. I want to write an iPhone application which can access that forum, any forum operation like browsing, reply, change profile, make it favourite post etc can be done in that iPhone application as well. I just wonder how to approach that, say what documents I should read first, what knowledge or technology I should master to do it? My idea is to start with reading CFNetwork programming guide and stream programming guide for cocoa. I also wonder if JSON and ASIHTTPRequest(http://allseeing-i.com/ASIHTTPRequest/How-to-use) could help. Can you guys point me a right direction to approach 开发者_开发问答writing this app? Any advice is appreciated!
Here is the code:
- (void) sendSyncHTTPRequest:(NSString *)request_data operation:(ServOperationSync *)serv_ops {
id<ServiceData> serv_data = serv_ops.dataDelegate;
NSURL *urlAddr = [NSURL URLWithString:[serv_data getServURL]];
urlRequest = [NSMutableURLRequest requestWithURL:urlAddr
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:90];
NSData *requestData = [request_data dataUsingEncoding:NSUTF8StringEncoding];
[urlRequest setValue:@"MobilePortal" forHTTPHeaderField:@"User-Agent"];
[urlRequest setValue:[serv_data getSoapAction] forHTTPHeaderField:@"SOAPAction"];
[urlRequest setValue:[NSString stringWithFormat:@"%u", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[urlRequest setValue:urlAddr.host forHTTPHeaderField:@"Host"];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:requestData];
NSLog(@"just before sending http request");
[serv_ops.responseData setData:[NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&urlResponse error:&urlError]];
NSLog(@"after sending http request");
}
Note that urlResponse and urlError are declared as instance variable.
For such an app it's best to make an iPhone web app as it requires no coding skills you dont already have (no need to learn objective-c).
Check out the safari section on developer.apple.com, with the help of some special meta and css tags you can make cool effects and nice user experience.
It will look and behave just like a "real" app.
Google "mozbx" (mobile zabbix) for a sample.
精彩评论