More than UI Sujith Krishnan 30SS
Foundation framework <ul><li>Common Classes </li></ul><ul><ul><li>String  NSString   NSMutableString </li></ul></ul><ul><u...
Collections – Array & Dictionary <ul><li>Retain the objects </li></ul><ul><li>Available as mutable and immutable </li></ul...
Autorelease ??? <ul><li>Framework take care of releasing the object </li></ul><ul><li>Factory methods are  autorelease  me...
Autorelease pool <ul><li>Pool of  autorelease  objects </li></ul><ul><li>Restrict the scope of  autorelease  objects </li>...
Autorelease -  A Scenario <ul><ul><li>(NSString*)someMethod{ </li></ul></ul><ul><ul><li>NSString *stringToReturn = nil; </...
Persistence <ul><li>Saving object state to a file </li></ul><ul><li>Should implement encoding methods </li></ul><ul><ul><u...
<ul><li>	mp </li></ul><ul><ul><li>temporary files used by f/w  </li></ul></ul><ul><li>Documents </li></ul><ul><ul><li>user...
Typical NSThread Use Case <ul><li>- (void)someAction:(id)sender </li></ul><ul><li>{ </li></ul><ul><li>// Fire up a new thr...
Delegates <ul><li>Define delegate methods </li></ul><ul><ul><li>@required   &  @optional </li></ul></ul><ul><li>Multiple o...
Accelerometer - Hints
Format Specifiers <ul><li>Same as what we use for rest of OOP </li></ul><ul><li>%@   - for NSString , Object , Date etc… <...
Upcoming SlideShare
Loading in...5
×

More than UI

1,323

Published on

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,323
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

More than UI

  1. 1. More than UI Sujith Krishnan 30SS
  2. 2. Foundation framework <ul><li>Common Classes </li></ul><ul><ul><li>String NSString NSMutableString </li></ul></ul><ul><ul><li>Array NSArray NSMutableArray </li></ul></ul><ul><ul><li>Dictionary NSDict.. NSMutableDict.. </li></ul></ul><ul><ul><li>File Handling NSFileManager </li></ul></ul><ul><ul><li>Persistance NSKeyedArchiver </li></ul></ul><ul><ul><li>Thread NSThread </li></ul></ul><ul><ul><li>Timer NSTimer </li></ul></ul><ul><ul><li>XML NSXmlParser </li></ul></ul><ul><ul><li>HTTP Connection NSURLReqest </li></ul></ul>
  3. 3. Collections – Array & Dictionary <ul><li>Retain the objects </li></ul><ul><li>Available as mutable and immutable </li></ul><ul><li>Direct persistence – writeToFile </li></ul><ul><li>Generic – can hold any objects </li></ul>
  4. 4. Autorelease ??? <ul><li>Framework take care of releasing the object </li></ul><ul><li>Factory methods are autorelease methods </li></ul><ul><li>Can call autorelease on any object </li></ul><ul><li>Write methods which will return autorelease objects </li></ul>
  5. 5. Autorelease pool <ul><li>Pool of autorelease objects </li></ul><ul><li>Restrict the scope of autorelease objects </li></ul><ul><li>Must to use in thread methods </li></ul><ul><li>Call retain to extend the scope of variable </li></ul><ul><ul><li>-(void)anyMethod{ </li></ul></ul><ul><ul><li>NSAutoreleasePool *pool = [[NSAuto… </li></ul></ul><ul><ul><li>// allocate a lot of memory (autorelease) </li></ul></ul><ul><ul><li>[pool release]; </li></ul></ul><ul><ul><li>} </li></ul></ul>
  6. 6. Autorelease - A Scenario <ul><ul><li>(NSString*)someMethod{ </li></ul></ul><ul><ul><li>NSString *stringToReturn = nil; </li></ul></ul><ul><ul><li>for (int i = 0; i < someLargeNumber; i++) { </li></ul></ul><ul><ul><li>NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; </li></ul></ul><ul><ul><li>NSString *string = ...; </li></ul></ul><ul><ul><li>string = [string stringByAppendingString:...]; </li></ul></ul><ul><ul><li>if ([string someCondition]) { </li></ul></ul><ul><ul><li>stringToReturn = [string retain]; </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>[pool release]; </li></ul></ul><ul><ul><li>if (stringToReturn) </li></ul></ul><ul><ul><li>break; </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>return [stringToReturn autorelease]; </li></ul></ul><ul><ul><li>} </li></ul></ul>
  7. 7. Persistence <ul><li>Saving object state to a file </li></ul><ul><li>Should implement encoding methods </li></ul><ul><ul><ul><li>Key – Value </li></ul></ul></ul><ul><ul><ul><li>NSKeyedArchiver </li></ul></ul></ul><ul><ul><ul><li>NSKeyedUnarchiver </li></ul></ul></ul><ul><li>Save in document directory </li></ul><ul><li>Can use SQLite3 also </li></ul>
  8. 8. <ul><li> mp </li></ul><ul><ul><li>temporary files used by f/w </li></ul></ul><ul><li>Documents </li></ul><ul><ul><li>user files </li></ul></ul><ul><li>Library </li></ul><ul><ul><li>application preferences, settings etc.. </li></ul></ul>Application Directories
  9. 9. Typical NSThread Use Case <ul><li>- (void)someAction:(id)sender </li></ul><ul><li>{ </li></ul><ul><li>// Fire up a new thread </li></ul><ul><li>[NSThread detachNewThreadSelector:@selector(doWork:) </li></ul><ul><li>withTarget:self object:someData]; </li></ul><ul><li>} </li></ul><ul><li>- (void)doWork:(id)someData </li></ul><ul><li>{ </li></ul><ul><li>NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; </li></ul><ul><li>[someData doLotsOfWork]; </li></ul><ul><li>// Message back to the main thread </li></ul><ul><li>[self performSelectorOnMainThread:@selector(allDone:) </li></ul><ul><li>withObject:[someData result] waitUntilDone:NO]; </li></ul><ul><li>[pool release]; </li></ul><ul><li>} </li></ul>
  10. 10. Delegates <ul><li>Define delegate methods </li></ul><ul><ul><li>@required & @optional </li></ul></ul><ul><li>Multiple object and single delegate definition </li></ul><ul><ul><li>Object comparison </li></ul></ul><ul><ul><li>Use of tag </li></ul></ul>
  11. 11. Accelerometer - Hints
  12. 12. Format Specifiers <ul><li>Same as what we use for rest of OOP </li></ul><ul><li>%@ - for NSString , Object , Date etc… </li></ul><ul><li>Can use positional specifiers </li></ul><ul><li>IEEE print specifications </li></ul>
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×