Skip to content

Instantly share code, notes, and snippets.

View Braeden-Mayer's full-sized avatar

- Braeden-Mayer

View GitHub Profile
@zaersk
zaersk / stocks.m
Last active August 29, 2015 14:04
BM
NSString *textString = @"APPL";
NSString *query = [NSString stringWithFormat:@"select * from yahoo.finance.quotes where symbol in (\"%@\")", textString];
NSString *escapedStoreUrl = [@"store://datatables.org/alltableswithkeys" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
NSString *escapedQuery = [query stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
NSString *urlString = [NSString stringWithFormat:@"http://query.yahooapis.com/v1/public/yql?q=%@&env=%@&format=json", escapedQuery, escapedStoreUrl];
NSMutableURLRequest *mutableRequestGET = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
[mutableRequestGET setHTTPMethod:@"GET"];
NSData *dataResponse = [NSURLConnection sendSynchronousRequest:mutableRequestGET returningResponse:nil error:nil];

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";