Connection / caching redsign thoughts
Reported by John Pope | May 13th, 2010 @ 12:35 AM
Hi Ryan, Josh
First thing - good job on this project. The website looks very
professional.
I wonder if you have plans to port this to android some time
soon?
Can I assert that the design of connection classes
connectiondelegate / connection / response should be reworked.
There have been bandaids been put in place to help app with this
(looking through some past tickets with refresh crashes) but I
think this needs some minor surgery.
The example on homepage
NSArray *dogs = [Dog findAllRemote];
while short and simple it has some design flaws.
I think the user should provide a selector to this method for
callback.
That is go off and search and when the results come (parse them in
background) then send array to appropriate function.
Eg.
[myFecher findAllRemote:Dog didFinishSelector:@selector(onFindDogs)
didFailSelector:@selector(onErrorsCatchAll)];
-(void) onFindDogs:(NSArray) array { NSArray *dogs = array; //send the array fully parsed straight to this function //here we can load data refresh list etc do whatever.... }
- (void) onErrorsCatchAll:(NSData) data { // display error // timeout popup . authentication issue // or even send the blasted rails error message to this function. // eg. Username too short. }
There are some classes from Google in the objective c package. The GdataHTTPFetcher which wraps around the NSURLConnection classes allowing http fetching with callback thus prevent app from locking up when a request is made. It also provides caching which we could immediately leverage to reduce requests.
GdataHTTPFetcher
GdataHTTPFetcherLogging
I recommend to review these.
// [myFetcher beginFetchWithDelegate:self //
didFinishSelector:@selector(myFetcher:finishedWithData:) //
didFailSelector:@selector(myFetcher:failedWithError:)];
Due to tight coupling of connection.m / response.m with to this
objective resource framework it looks difficult to implement these
classes without breaking everything. While I'm confident this can
be done, I'm looking into some buy in from others in getting behind
this before I start yet another fork. By the way has anyone look at
the current forks in project? http://github.com/yfactorial/objectiveresource/network
There are some improvements in these forks that should be merged to
trunk.
I think by simply include the GDatafetcher class in OR package and stripping out the connectiondelegate / response class would help make this more production worthy.
I am happy to help implement this.
P.S. I have some sample ruby code that you might like to help build objective c scaffold that I'm attaching. It will automatically build sample based on some parameters eg. instead of dog / person > user / books
Your thoughts
JP
No comments found
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Port of Rails' ActiveResource framework to the iPhone.