- (void)playAlarmSound:(NSTimer *)theTimer {
static SystemSoundID soundID/* = 0 */; // ?
if (!soundID) {
soundID = [Utilities createSystemSoundIDFromFile:@"beep" ofType:@"caf"];
}
...
}
SystemSoundID(這是一個UInt32)自動分配0?或者我應該明確地分配它?我必須這樣做,然後測試它是否未被Utilities方法初始化,因爲如果我只是執行static SystemSoundID soundID = [Utilities createSystemSoundIDFromFile:@"beep" ofType:@"caf"];
,它就不會編譯。起初我嘗試將它分配給NULL,但後來我意識到它不是一個指針,所以無論如何,我應該在那裏還是它是多餘的?Objective C - SystemSoundID的(typedef'd UInt32)是否自動分配0?