hi,
how can i create an array of 25 images???
pls help
hi,
how can i create an array of 25 images???
pls help
First, you need to get the images into your application. You can select all 25, then drag them to the Resources folder in the Groups & Files pane in Xcode (this is the way to do it in Xcode 3, I’m not sure if it’s the same in Xcode 4).
When the panel drops down, be sure to check the check box at the top for “copy items into destination group folder”.
You then need to create NSImages from the files using the imageNamed_ method. You could do this one image at a time, but the code below will add them all if they all have the same file extension (JPG in my example):
set picArray to current application's NSMutableArray's array()
set mb to current application's NSBundle's mainBundle()
set theURLs to mb's URLsForResourcesWithExtension_subdirectory_("JPG", missing value)
repeat with aURL in theURLs
set thePic to current application's NSImage's imageNamed_(aURL's lastPathComponent())
picArray's addObject_(thePic)
end repeat
Ric