我正在使用以下代碼將許多圖像加載到數組中,但想知道如何更有效地執行此操作。例如,我怎樣纔能有效地將100張圖片加載到數組中?如何將多個對象添加到數組中
hopAnimation=[[NSArray alloc] initWithObjects:
[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-100.png"],
nil
];
有沒有辦法使用for-loop來有效地做到這一點?
是什麼讓你認爲你所做的事情效率不夠高? –