I have the following table in my database:
Questions
int:questionId(PK)
varchar:questionTitle
int:questionNumber
int:sectionId(FK)
I have built pretty much the same structured class in objective c
#import <Foundation/Foundation.h>开发者_开发问答
@interface Question : NSObject {
NSInteger qId;
NSString* qTitle;
NSInteger qNumber;
}
@property (nonatomic) NSInteger qId;
@property (nonatomic, retain) NSString* qTitle;
@property (nonatomic) NSInteger qNumber;
@end
#import "Question.h"
@implementation Question
@synthesize qId, qTitle, qNumber;
@end
My question is, is there anyway to map the structures? do compatibility frameworks exist for iphone php communication?
e.g. get php to echo an object array and assign elements to question objects
You'll need to build a small "service" that encodes your items in json and returns them via http, here's the docs for that:
http://php.net/manual/en/ref.json.php
As Katfish above mentioned, you'll want ot use the SBJSON[1] library in your project in combination with the NSURLConnection/NSURLRequest or the ASIHTTP[2] library. ASIHTTP is probably easier if you aren't familiar with either method of http access in Cocoa/Obj-C.
Here's a good example:
http://blog.zachwaugh.com/post/309924609/how-to-use-json-in-cocoaobjective-c
[1] http://code.google.com/p/json-framework/
[2] http://allseeing-i.com/ASIHTTPRequest/
精彩评论