Last active
August 29, 2015 14:07
-
-
Save reddragon/319b2a89d6bbb5ca0836 to your computer and use it in GitHub Desktop.
iOS Week 1 - Class 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pttrns.com => For patterns. | |
Reference Counting (arc). | |
@ for NSLiteral, so that "" doesn't mean C-string. | |
Set tableView delegate and dataSource = self. | |
Set numberOfRowsInSection | |
Set cell | |
Use a navigation controller, to use the movies view controller, and set the root view controller as the new navigation controller. | |
TableView does not load all the contents of all the rows at once. It sets them up on a need-to-use basis. It kicks out the contents of cells not being seen. | |
Create a subclass of TableViewCell, MovieCell. Set labels, set 0 as the number of lines in the summary label. | |
Now, back to MoviesViewController. | |
self.tableView registerNib:[UINib:nibWithNibName:@"" for CellReuseIdentifier@"MovieCell". In cellForRowAtIndexPath [tableView dequeueReusableCellWithIdentifier:@"MovieCell"] | |
In viewDidLoad, create an NSURL *url. Also, create a request: | |
NSURL *req = [[NSURLRequest alloc] initWithURL:url]; | |
[NSURlConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:(..) { | |
NSDictionary *responseDictionary = [NSJSONSerialization JSONOb | |
self.movies = responseDictionary[@"movies"] | |
No NPE in ObjC :-| nil.size returns 0. | |
Set the title and synopsis, and reloadData. | |
Tip: Don't name your outlet of an Image View as 'imageView'. That will clash with the TableView. Now, get the url. | |
ObjC: [movie valueForKeyPath:@"posters.thumbnail"]; // Nested access of keying in a dictionary. | |
Use CocoaPod, set up AFNetworking | |
ObjC: can add methods even after class has been declared. | |
#import "UIImageView+AFNetworking.h" | |
[cell.posterView setImageWithURL] <= Not a part of CocoaTouch, its in AFNetworking. | |
XCode: key-value coding compliant => missing connection. | |
XCode: NSRangeException Set exception handler. | |
tableView didSelectRowAtIndexPath to do some work around. | |
pushViewController to get to the detail view controller. | |
ScrollViews are dumb. You need to tell them how big is your text. TableView is derived from ScrollView. You can set the scroll size. Parallax view => register callbacks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment