2012-11-25 67 views
1

我正在學習在Mountain Lion 10.8.2中使用Xcode Version 4.5.2創建動畫的教程。當試圖建立下面的代碼,我在節目得到解析錯誤意外「@」顯示出來的「hopAnimation =」線。在搜索時,我發現了以不同方式構建簡單動畫的示例,但似乎沒有解決這個特定問題的示例。我是XCode編程的小老婆,如果有人能幫我糾正語法,我會非常感謝。我還要感謝Stackflow的所有貢獻者提供這樣一個寶貴的資源。搜索我之前大多數問題的答案似乎總是讓你們在結果列表的頂部。XCode構建解析錯誤'Unexpected @ in Program'



    ViewController.m 
    - (void)viewDidLoad 
    { 
     // load all the frames of our animation into an array 
     NSArray *hopAnimation; 
     hopAnimation=[[NSArray alloc] arrayWithObjects: 
         [UIImage imageNamed:@」frame-1.png」], 
         [UIImage imageNamed:@」frame-2.png」], 
         [UIImage imageNamed:@」frame-3.png」], 
         [UIImage imageNamed:@」frame-4.png」], 
         [UIImage imageNamed:@」frame-5.png」], 
         [UIImage imageNamed:@」frame-6.png」], 
         [UIImage imageNamed:@」frame-7.png」], 
         [UIImage imageNamed:@」frame-8.png」], 
         [UIImage imageNamed:@」frame-9.png」], 
         [UIImage imageNamed:@」frame-10.png」], 
         [UIImage imageNamed:@」frame-11.png」], 
         [UIImage imageNamed:@」frame-12.png」], 
         [UIImage imageNamed:@」frame-13.png」], 
         [UIImage imageNamed:@」frame-14.png」], 
         [UIImage imageNamed:@」frame-15.png」], 
         [UIImage imageNamed:@」frame-16.png」], 
         [UIImage imageNamed:@」frame-17.png」], 
         [UIImage imageNamed:@」frame-18.png」], 
         [UIImage imageNamed:@」frame-19.png」], 
         [UIImage imageNamed:@」frame-20.png」],nil]; 

     self.bunnyView1.animationImages=hopAnimation; 
     self.bunnyView2.animationImages=hopAnimation; 
     self.bunnyView3.animationImages=hopAnimation; 
     self.bunnyView4.animationImages=hopAnimation; 
     self.bunnyView5.animationImages=hopAnimation; 
     self.bunnyView1.animationDuration=1; 
     self.bunnyView2.animationDuration=1; 
     self.bunnyView3.animationDuration=1; 
     self.bunnyView4.animationDuration=1; 
     self.bunnyView5.animationDuration=1; 
     [super viewDidLoad]; 
    } 

回答

2

沒有初始化方法,稱爲arrayWithObjects。有initWithObjects,或簡單地[NSArray arrayWithObjects](沒有分配),但這是行不通的。此外,你的報價是「精明的報價」,捲曲的報價。我不知道在Xcode中是不是這樣,但是你可能不得不用直引號(「)來使其工作。」

+0

OMFG ....它是捲曲引號而不是直引號。這就是我成爲一個懶惰的SoB並從代碼示例中進行「剪切和粘貼」所得到的結果。謝謝你指出除了我之外的其他人。:)〜 – Grymjack