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 memorymanagement theres typically no need to keep a reference to a timerafter you’ve scheduled it. Since the timer is passed as an argumentwhen you specify its method as a selector, you can invalidate arepeating timer when appropriate within that method. In manysituations, however, you also want the option of invalidating the timer—perhaps even before it starts. In this case, you do need to keep areference to the timer, so that you can send it an invalidate messagewhenever appropriate. If you create an unscheduled timer (see“Unscheduled Timers”), then you must maintain a strong reference to thetimer (in a reference-counted environment, you retain it) so that it is notdeallocated before you use it.
參考資料補充• How do I use NSTimer (http://stackoverﬂow.com/questions/1449035/how-do-i-use-nstimer)• 計算碼錶經過的時間差 (http://stackoverﬂow.com/questions/3519562/how-do-i-write-a-timer-in- objective-c)• 在 NSTimer 中使⽤用 userInfo (http://www.adamzucchi.com/blog/?p=41)
View CoordinatesCGFloatCGPoint 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 /