Thursday, 5 September 2013

How to count the number of files starting with a specific string in Xcode (Objective-C)?

How to count the number of files starting with a specific string in Xcode
(Objective-C)?

I'm new to Xcode and programming in general so forgive me if this is a
stupid question.
I have a series of images in the 'resources' folder of my app. They're
named 'thing1_01.png', 'thing1_02.png', 'thing2_01.png', and so on. I have
a piece of code which puts these images into a dynamic scrollview based on
which 'thing' is currently selected.
Presently my scrollview is set to show a fixed 3 images, which it does
very nicely. However, not every 'thing' will have exactly 3 images, so I
would like xcode to figure out how many pictures I have for each item.
Is it possible to perform a count on the number of files in my directory
which start with (or include at any point) a specific string, for example
everything that includes 'thing1'?

No comments:

Post a Comment