我正在設計一個老虎機項目,其中有高分頁面的第二個視圖。大多數情況下,除了將老虎機從老虎機傳遞到高分頁之外,所有的東西都可以工作。這裏是我的方法的代碼老虎機內:將值從一個類傳遞到另一個類
if(win == YES) {
NSString *msg = nil;
if(playerField.text.length > 0) {
msg = [[NSString alloc] initWithFormat:@"%@", playerField.text];
}
NSLog(@"DEBUG");
[(HighScorePage *)self.view addNewHighScore:msg];
[self performSelector:@selector(playWinSound) withObject:nil afterDelay:.5];
[msg release];
}
,這裏是在HighScorePage的addNewHighScore方法:
-(void)addNewHighScore:(NSString *)player {
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
int i = 0;
for (NSArray *count in dynPlayerArray) {
[tempArray addObject:[NSIndexPath indexPathForRow:i++ inSection:0]];
}
[tempArray addObject:player];
[[self highScores] beginUpdates];
[[self highScores] insertRowsAtIndexPaths:(NSArray *)tempArray withRowAnimation:UITableViewRowAnimationNone];
[[self highScores] endUpdates];
[tempArray release];
}
還是新的,在這一點,所以讓我知道你認爲!謝謝!
哪裏是如果(贏得== YES)這種說法? – saadnib 2011-04-06 16:23:08
在我的IBAction中稱爲spin,每當用戶點擊一個按鈕時調用。它讓我的老虎機旋轉並播放聲音和東西。這是所有功能,我需要知道的是如何將字符串從一個類傳遞到另一個 – SForemann 2011-04-07 14:36:46
,這是所有功能* – SForemann 2011-04-07 14:37:08