Skip to content

Instantly share code, notes, and snippets.

View csmobile's full-sized avatar

ciara staggs csmobile

View GitHub Profile
@csmobile
csmobile / gist:a3215d3f465a4a225107
Created May 21, 2014 20:11
easy concatenation of strings in iOS
// NSString *string1 = _textField1.text;
// NSString *string2 = _textField2.text;
// NSLog(@"contents are: %@, %@", string1,string2);
//[NSString stringWithFormat:@"%@%@", string1, string2];
@csmobile
csmobile / gist:f2390310d4882b595c18
Created June 3, 2014 19:59
javascript jquery include(s) example code snippet
<script>
$(“#header”).load(“header.html”);
$(“#footer”).load(“footer.html”);
</script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script>$(“#footer”).load(“footer.html”);</script>
@csmobile
csmobile / gist:55f49d767fb2460a2175
Created July 1, 2014 17:48
Parse JSON to object
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:&error];//response object is your response from server as NSData
if ([json isKindOfClass:[NSDictionary class]]){ //Added instrospection as suggested in comment.
NSArray *yourStaffDictionaryArray = json[@"directory"];
if ([yourStaffDictionaryArray isKindOfClass:[NSArray class]]){//Added instrospection as suggested in comment.
for (NSDictionary *dictionary in yourStaffDictionaryArray) {
Staff *staff = [[Staff alloc] init];
staff.id = [[dictionary objectForKey:@"id"] integerValue];
staff.fname = [dictionary objectForKey:@"fName"];
staff.lname = [dictionary objectForKey:@"lName"];