Skip to content

Instantly share code, notes, and snippets.

@lifely
Last active August 29, 2015 14:15
Show Gist options
  • Save lifely/0005075d9ba80e827827 to your computer and use it in GitHub Desktop.
Save lifely/0005075d9ba80e827827 to your computer and use it in GitHub Desktop.
Fail or Continue - Paradigme
NSArray *developerList = nil;
if (!responseObject || !(developerList = [responseObject objectForKey:@"list"]) ||
![developerList isKindOfClass:[NSArray class]])
return ; // call error/failure block
NSArray *developers = [SFService prepareObjectFromResponse:developerList forObjectClass:[SFDeveloper class]];
NSLog(@"[SUCCESS][SFService-api] Action /trombi/ : \n%@", developers);
@lifely
Copy link
Author

lifely commented Feb 19, 2015

Three years later, lifely replies !

So, i agree with what you were saying and it's all fine. However the code on this gist was more of an concept example than a real issue.

I was mostly referring about the way to organise, the flow of your code. In order to achieve a more linear reading experience, i usually write my code like the above :

  • request
  • check for failure or (request, assign and check for failure on the same line)
    • handle failure
  • rest of the function is the logical code of the function

I have moved on a little with swift and have more background on it now, so i see what i was doing wrong and what can be done now, i still have to figure some things but i have time.

However i'll point out one link: http://ericasadun.com/2015/02/16/swift-linearizing-code/ by erica sadun, it's exactly what i was trying to reproduce and she probably explain it better than i do.

Thanks, cc @apouche

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment