35. NSTimer 記憶體使⽤用問題
Note also the point on Memory Management at the bottom of the article:
Because the run loop maintains the timer, from the perspective of memory
management there's typically no need to keep a reference to a timer
after you’ve scheduled it. Since the timer is passed as an argument
when you specify its method as a selector, you can invalidate a
repeating timer when appropriate within that method. In many
situations, however, you also want the option of invalidating the timer—
perhaps even before it starts. In this case, you do need to keep a
reference to the timer, so that you can send it an invalidate message
whenever appropriate. If you create an unscheduled timer (see
“Unscheduled Timers”), then you must maintain a strong reference to the
timer (in a reference-counted environment, you retain it) so that it is not
deallocated before you use it.
37. 參考資料補充
• How do I use NSTimer
(http://stackoverflow.com/questions/1449035/how-do-i-use-nstimer)
• 計算碼錶經過的時間差
(http://stackoverflow.com/questions/3519562/how-do-i-write-a-timer-in-
objective-c)
• 在 NSTimer 中使⽤用 userInfo
(http://www.adamzucchi.com/blog/?p=41)
42. View Coordinates
CGFloat
CGPoint
C struct with two CGFloats in it: x and y.
CGPoint p = CGPointMake(34.5, 22.0);
p.x += 20; / move right by 20 points
/
CGSize
C struct with two CGFloats in it: width and height.
CGSize s = CGSizeMake(100.0, 200.0);
s.height += 50; / make the size 50 points taller
/
CGRect
C struct with a CGPoint origin and a CGSize size.
CGRect aRect = CGRectMake(45.0, 75.5, 300, 500);
aRect.size.height += 45; / make the rectangle 45 points taller
/
aRect.origin.x += 30; / move the rectangle to the right 30 points
/