• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Images in folder - simple question?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Images in folder - simple question?


  • Subject: Re: Images in folder - simple question?
  • From: Stefan Pantke <email@hidden>
  • Date: Wed, 28 Jan 2004 14:13:51 +0100

Dominik,

First of all, locate and download CocoaBrowser, a tool to easily browse
cocoas documentation. At least my favorite...

Am 28.01.2004 um 12:41 schrieb Dominik Gwosdek:

Hi,

I'm starting to learn cocoa and objective-c

Good Idea ;-)

and I'm trying to write a little app that has an NSImageView and only two buttons (back, forward) and a folder with ca. 100 pictures(001.jpg ... 100.jpg).

It would be best to allow the user choose a specific folder.
But for now, you might use a static path - hardcoded in your application.

I have set up an outlet to the ImageView and two actions for the buttons.Now I need a little advice to implement the following action:


You probably need two more outlets connected to the buttons, if you are
at the beginning or the end of your list.

when the user clicks on for example on the forward button the ImageView should display the next image from the folder(/images) and so on.

I think I need to create an NSArray (with the content of a folder?).


Yes, this might be a solution.
Open the specific folder and load all documents of the folder in the array.

Have a look at NSFileManager. This class helps do you some generic file stuff.
Cocoa has a default NSFileManager. Locate it using it's method defaultManager.
Use enumeratorAtPath to enumerate all document of your specific type at
some specific path. Just like this:

>>>
NSString *file;
NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager]
enumeratorAtPath:@"/MyAccount/Documents"];
while (file = [enumerator nextObject]) {
if ([[file pathExtension] isEqualToString:@"doc"])
[self scanDocument:file];
}
<<<

Now that you are enumerating the documents, put them in your array,
using addObject of NSArray.

Have a look at NSImageView, which does all the stuff of presenting the
images to your user.
Try setImage to set an image - composed of the absolute path and it's
enumerated file name - to the NSImageView.

Since NSImageView is an anscestor of NSControl, you use NSControl's
methods. For example, you may use it's methods to update the the
NSView.

Check, what's happening, when you setImage your image. Do you need
to update manually?

- (IBAction)forwardButton:(id)sender
{

image = [NSImage imageNamed:@"001"];
[showImage setImage: image];

}


If more help is needed, as cocoa-dev!

Have fun,

Stefan

Thank you in advance.

Dominik
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Images in folder - simple question?
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: Images in folder - simple question?
      • From: email@hidden (Dominik Gwosdek)
    • Re: Images in folder - simple question?
      • From: email@hidden (Dominik Gwosdek)
References: 
 >Images in folder - simple question? (From: email@hidden (Dominik Gwosdek))

  • Prev by Date: sscanf problem
  • Next by Date: Re: Images in folder - simple question?
  • Previous by thread: Images in folder - simple question?
  • Next by thread: Re: Images in folder - simple question?
  • Index(es):
    • Date
    • Thread