1.+(void)initialize {
if (self == [MyCustomClass class]) {
// do your stuff here!
}
}

2. dont call [NSNotificationCenter removeObserver:] excepet dealloc

3.

Handy constants

Another element that is easily overlooked, but can make code and life so much easier: Convenience Constants. Take some examples:

  • CGPointZero
  • CGRectZero
  • CGSizeZero
  • CGRectInfinite – mostly used in Core Image contexts
  • CGRectNull – not equal to CGRectZero, returned by e.g. CGRectIntersection()
  • NSNotFound
  • CGAffineTransformIdentity
  • UIEdgeInsetsZero
  • UITrackingRunLoopMode
  • NSFoundationVersionNumber
  • NSRunLoopCommonModes
  • NSEventTrackingRunLoopMode
  • 

    发表评论

    You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    CAPTCHA image