0
你好是我使用加信到字符串目標C若跌破聲明
currentCardDisplayed = [NSMutableString stringWithFormat:@"%@.png", [[cardsShuffled objectAtIndex:currentCard-1] substringToIndex:[[cardsShuffled objectAtIndex:currentCard-1] length]-1]];
NSString *rule;
if([[currentCardDisplayed stringByAppendingString:@"e"] isEqualToString:currentCardName]){
rule = @"drink";
}else if([[currentCardDisplayed stringByAppendingString:@"2"]isEqualToString:currentCardName]){
rule = @"drink2";
}else if([[currentCardDisplayed stringByAppendingString:@"3"]isEqualToString:currentCardName]){
rule = @"drink3";
}else if([[currentCardDisplayed stringByAppendingString:@"4"]isEqualToString:currentCardName]){
rule = @"drink4";
}else if([[currentCardDisplayed stringByAppendingString:@"5"]isEqualToString:currentCardName]){
rule = @"drink5";
}else if([[currentCardDisplayed stringByAppendingString:@"6"]isEqualToString:currentCardName]){
rule = @"drink6";
}else if([[currentCardDisplayed stringByAppendingString:@"7"]isEqualToString:currentCardName]){
rule = @"drink7";
}else if([[currentCardDisplayed stringByAppendingString:@"8"]isEqualToString:currentCardName]){
rule = @"drink8";
}else if([[currentCardDisplayed stringByAppendingString:@"9"]isEqualToString:currentCardName]){
rule = @"drink9";
}else if([[currentCardDisplayed stringByAppendingString:@"0"]isEqualToString:currentCardName]){
rule = @"drink10";
}else if([[currentCardDisplayed stringByAppendingString:@"k"]isEqualToString:currentCardName]){
rule = @"drinkjack";
}else if([[currentCardDisplayed stringByAppendingString:@"n"]isEqualToString:currentCardName]){
rule = @"drinkqueen";
}else if([[currentCardDisplayed stringByAppendingString:@"g"]isEqualToString:currentCardName]){
rule = @"drinkking";
}
NSLog(@" %@ ", currentCardDisplayed);
NSLog(@" %@ ", currentCardName);
NSLog(@"%@", rule);
NSLog(@" %@", [cardsShuffled objectAtIndex:currentCard-1]);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Rules" message:rule delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
[alert show];
我試圖添加到末尾的字母沒有到達那裏的代碼。我首先刪除了一個字母,但是然後在我的if語句中,我想檢查是否向該變量添加了另一個字母,它等於另一個字符串。
任何人都可以看到我錯了
下面是從
2012-12-11 20:06:50.853 Kings_1.03[4915:c07] club.png
2012-12-11 20:06:50.855 Kings_1.03[4915:c07] club9.png
2012-12-11 20:06:50.857 Kings_1.03[4915:c07] (null)
2012-12-11 20:06:50.858 Kings_1.03[4915:c07] club9
任何幫助表示讚賞
的nslogs輸出樣品感謝你
笏做你的意思,你能舉出一個你認爲不錯的例子嗎?或者這是你的意思,如果([[currentCardDisplayed stringByAppendingString:@「e.png」] isEqualToString:currentCardDisplayed]){0} {0}條規則@ @「drink」; } –
@AlanFletcher,不,只要在第一行中定義currentCardDisplayed時不添加.png,那麼測試就可以工作。 – rdelmar
@AlanFletcher,很抱歉,不會因爲您將它與具有.png的字符串進行比較而無法正常工作。 – rdelmar