Your SlideShare is downloading. ×
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Objective C Tricks
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Objective C Tricks

824

Published on

Gives a brief introduction into some of the hidden tips and tricks with coding using Objective C, It gives examples for Literals ,Sub-scripting , Method swizzling

Gives a brief introduction into some of the hidden tips and tricks with coding using Objective C, It gives examples for Literals ,Sub-scripting , Method swizzling

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

No Downloads
Views
Total Views
824
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
26
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 1
  • 2.  The following is the old way of writing code: 2
  • 3. 3
  • 4.  You can use subscripting to access the values inside dictionaries and arrays. This is how the syntax looks: 4
  • 5.  We can dynamically generate classes and selectors from strings, We do this by using the NSClassFromString and NSSelectorFromString functions:  NSClassFromString will return nil if there isn't a class in the runtime that matches the string 5
  • 6.  We can also decide in run time which selector to be called based on input: * Required 6
  • 7.  Methods are made up of two components. The selector, which is an identifier for a method, and the IMP, which is the actual implementation that is run. One of the key things about this separation is that a selector and IMP link can be changed. One IMP can have multiple selectors pointing to it.  Subclassing -> This allows you to override a method and call the original implementation, but it means that you have to use instances of this subclass.  Category -> you cannot call the original implementation if you override a method.  Swizzling -> You can override a method without subclassing AND call the original implementation * Required 7
  • 8.  make a UINavigationBar green T  this will change all navigation bars in the app to green, but if I used UIImagePickerController it will be changed too!!!. We have to find new way for that >>>>> Method Swizzling  8
  • 9.  Method swizzling, in short, is switching methods at runtime. So you can say for UINavigationBar don’t use the standard drawRect:, but instead swap it with a different one * Required 9
  • 10.  Here is the swizzling: 10
  • 11.  measure how long the synchronize takes in NSUserDefaults * Required 11
  • 12. 12
  • 13. Borders around all UIViews  initWithFrame: get a red border, views that were unarchived (for example as part of XIBs) get a blue border.  13
  • 14. Surprise  the status bar at the top of an iOS app is drawn by the app itself  14
  • 15. * Required 15
  • 16. * Required 16
  • 17.  objc_msgSend() This function takes a target, a selector and a list of arguments 17
  • 18.  Shrink CGRect:  Different insets for each edge: using UIEdgeInsets(top, left, bottom, right) 18
  • 19.  CGRectUnion is UIScrollView’s best friend: if you want use UIScrollView with bunch of subviews, so you have to know only the topleft and bottom-right views: 19
  • 20. Print CGRect values :  Dictionary Representation (to store in in plist on disk): 20
  • 21.  Storing it in Obj-C Storage Classes 21
  • 22. Any Questions? 22

×