我有一個NSDictionary包含的價值,我需要得到這個值 我已經嘗試使用下面的代碼來獲取值:轉換的NSDictionary值NSInteger的
[NSTimer scheduledTimerWithTimeInterval:0.01
target:self
selector:@selector(timerMovelabel:)
userInfo:
[NSDictionary dictionaryWithObject:var forKey:@"var1"]
, [NSMutableDictionary dictionaryWithObject:[NSNumber numberWithInt:23] forKey:@"var2"]
我試圖獲得的價值使用以下方法
int intvar = [[[timer userInfo] objectForKey:@"var2"] intValue];
NSNumber *numbervar = [[timer userInfo] objectForKey:@"var2"]; NSInteger intvar = [num intValue];
如下:
[self method:[[[timer userInfo] objectForKey:@"var2"] intValue]]; - (void)timerMovelabel:(NSTimer *)timer { //here i execute one of the steps 1,2 and 3 but i didn't get any result all values are null } - (void) method:(NSInteger)dir { NSLog(@"%d",dir); }
請使用提供的編輯器工具格式化代碼,否則會導致閱讀困難。 – 2011-01-05 16:07:42
請描述這不符合您的期望以及您看到的任何警告或錯誤。它看起來像你試圖傳遞一個逗號分隔字典列表作爲你的'userInfo'參數,這沒有任何意義。向我們展示您實際使用的代碼,而不僅僅是從上下文中選擇線。 – Jonah 2011-01-05 16:21:03
您錯過了'NSTimer'類方法中的'repeats'參數。 – 2011-01-05 16:27:45