Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]
On May 23, 2008, at 5:19 PM, Sean McBride wrote: On 5/22/08 4:37 PM, Lynn Barton said: From what I have read quickly since Sean McBride sent his comment, UTIs are not yet implemented to the point where I could get the UTI of every file on my computer. Sure you can. Use LSCopyItemAttributes() with kLSItemContentType. I've written a category on NSFileManager that, among other things, will do this. Here's the relevant portion for you: __ #import Foundation/Foundation.h @interface NSFileManager (DSFileAdditions) + (NSString *)UTIForFile:(NSString *)path; + (NSString *)UTIForURL:(NSURL *)url; @end @implementation NSFileManager (DSFileAdditions) + (NSString *)UTIForFile:(NSString *)path { return [self UTIForURL:[NSURL fileURLWithPath:path]]; } + (NSString *)UTIForURL:(NSURL *)url { NSString *retval = nil; FSRefPtr fileRef = NULL; fileRef = calloc( 1, sizeof( FSRef ) ); if ( (fileRef != NULL) (url != nil) [url isFileURL] (CFURLGetFSRef( (CFURLRef)url, fileRef ) == true) ) { CFStringRef theUTI = NULL; if ( LSCopyItemAttribute( fileRef, kLSRolesAll, kLSItemContentType, (CFTypeRef *)theUTI ) == noErr ) { retval = [[(NSString *)theUTI copy] autorelease]; CFRelease( theUTI ); } } if ( fileRef != NULL ) free( fileRef ); return retval; } __ I *think* this code should work fine under GC (for anyone using it), but you should probably test it first as I haven't. -- Darkshadow (aka Michael Nickerson) http://www.nightproductions.net smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSCollectionView problems
Hello again, On May 23, 2008, at 1:20 PM, Markus Spoettl wrote: I have an NSCollectionView set up with bindings to visualize an NSMutableArray. When I call arrayController:setContent: the view (which initially doesn't have a content assigned) displays the items. So far so good. The problems are these: If there are two many items for one page to display, the vertical scroller appears. However, it's not the correct size. It's displayed as if all items would fit into the view (all but an imaginary 10 pixel row). It doesn't get the correct size until after the view is resized. Is there some way to force the view to recalculate it's scroll bar sizes? Or could this be caused by how the content is assigned (I'm using an array controller)? The second problem is when the view is resized (due to window resizing or any other reason). When the collection view is scrolled down with some item in the middle of the collection selected (so the scrollbar is not on it's topmost position), the resize causes the collection display to jump to the first item row. This problem can be observed in the Apple supplied IconCollection demo. Is there a way to prevent that? For those interested, both issues go away if Automatically Hide Scrollers is switched OFF for the enclosing scroll view. I had scrollers switched off by default for esthetic reasons. Apparently NSCollectionView can't handle that case properly. Does anyone know is this a known issue? If not I'd be glad to file a report. Regards Markus -- __ Markus Spoettl smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Cleaning up a singleton
Hi, I have a bit of an odd problem, which may be the result of a bad design decision. My program wraps around a C library, which internally uses a global variable (structure) to manage things, and has functions to access the data. The library requires me to call a function which allocates memory to that global variable, and afterwards call a function which deallocates that memory. My singleton class calls the function to initialise in the init method, but I don't know how to deallocate the memory. Since singleton objects exist until the end of program execution, I assume dealloc wouldn't work with garbage collection. Calling dealloc on a singleton object doesn't even make sense. How would I handle this? -- Sebastian Nowicki ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Query about Zip command
On 23 May 08, at 21:22, parag vibhute wrote: But my requirement is to pass arguments to GUI apps while launching it is it possible using Launch services? I will post my code of NSTask for launching GUI app in 1-2 days as my Mac is in office. GUI applications generally do not take arguments - opened files are passed using Apple Events. Hence, Launch Services doesn't provide any way to pass arguments. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSURLConnection canHandleRequest: succeeds even with no network
Why does [ NSURLConnection canHandleRequest: ] return YES even if I turn off all my network connections? I thought this method was supposed to be used for preflighting connection requests? Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleaning up a singleton
Hi, Would the following NSApplication methods, placed into your application delegate's code, help at all? - (void)applicationDidFinishLaunching:(NSNotification *)aNotification; - (void)applicationWillTerminate:(NSNotification *)aNotification; Of the latter, the docs say that one should Put any necessary cleanup code in this method. Cheers, Andrew On May 23, 2008, at 11:07 PM, Sebastian Nowicki wrote: Hi, I have a bit of an odd problem, which may be the result of a bad design decision. My program wraps around a C library, which internally uses a global variable (structure) to manage things, and has functions to access the data. The library requires me to call a function which allocates memory to that global variable, and afterwards call a function which deallocates that memory. My singleton class calls the function to initialise in the init method, but I don't know how to deallocate the memory. Since singleton objects exist until the end of program execution, I assume dealloc wouldn't work with garbage collection. Calling dealloc on a singleton object doesn't even make sense. How would I handle this? -- Sebastian Nowicki ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/andrew.merenbach%40ucla.edu This email sent to [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Query about Zip command
Am 24.05.2008 um 08:08 Uhr schrieb Andrew Farmer: GUI applications generally do not take arguments - opened files are passed using Apple Events. Hence, Launch Services doesn't provide any way to pass arguments. You can use Apple Events yourself, though. See NSWorkspace's - launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier : Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleaning up a singleton
Am 24.05.2008 um 08:07 Uhr schrieb Sebastian Nowicki: The library requires me to call a function which allocates memory to that global variable, and afterwards call a function which deallocates that memory. My singleton class calls the function to initialise in the init method, but I don't know how to deallocate the memory. [...] How would I handle this? Um. You don't? Since all memory is reclaimed when the application quits, deallocating a singleton to free memory is not necessary. If, for some other reason, you need to act when the application quits, you can register for the NSApplicationWillTerminateNotification notification. Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Query about Zip command
On May 23, 2008, at 11:08 PM, Andrew Farmer wrote: On 23 May 08, at 21:22, parag vibhute wrote: But my requirement is to pass arguments to GUI apps while launching it is it possible using Launch services? I will post my code of NSTask for launching GUI app in 1-2 days as my Mac is in office. GUI applications generally do not take arguments - opened files are passed using Apple Events. Hence, Launch Services doesn't provide any way to pass arguments. LSOpenURLsWithRole does, sort of: LSApplicationParameters has an argv field which the docs say it's unused on 10.4. No idea if it's used on 10.5 (or even if the question is related to the subject any more...as others have said, NSTask is the obvious solution for /usr/bin/zip). -- Adam ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Removing the Filename flag in Doc. based Application
On May 23, 2008, at 2:51 PM, [EMAIL PROTECTED] wrote: How do I set my document based application to omit the filename reference at the top of each opened document window? Kyle Sluder's explanation is quite informative, but it may also be more complicated than you need. If you really just want to change the name of your document, you can override -[NSDocument displayName] like this: // Adding this method to your document subclass will cause the // title of every document window to be Foo. - (NSString *)displayName { return @Foo; } If you want to also remove the file proxy icon (small icon next to the window title), you'll likely want to create a custom window controller as described by Kyle and implement either the - windowDidLoad: or -awakeFromNib methods such that you get a reference to the icon button and send it a -setHidden: message, like this: // Put the following in your custom window controller where it'll // be executed soon after the window is loaded. NSButton *fileButton = [window standardWindowButton:NSWindowDocumentIconButton]; if (fileButton != nil) { [fileButton setHidden:YES]; } The reason for putting the code above in a custom window controller is that ideally, your document class shouldn't be in the business of defining what the window should look like. The window controller is a better place for that. cheers, Caleb Strockbine ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Query about Zip command
I am launching my app through applet. So passing arguments as command line is only current solution for me. Thanks, Palav On 5/24/08, Andreas Mayer [EMAIL PROTECTED] wrote: Am 24.05.2008 um 08:08 Uhr schrieb Andrew Farmer: GUI applications generally do not take arguments - opened files are passed using Apple Events. Hence, Launch Services doesn't provide any way to pass arguments. You can use Apple Events yourself, though. See NSWorkspace's - launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier : Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/parag.vibhute%40gmail.com This email sent to [EMAIL PROTECTED] -- There are many things in your life that will catch your eye but only a few will catch your heartpursue those'. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Query about Zip command
Sorry for my last email. That comment was incorrect(I was thinking something else). Sorry again. I will try with launchAppWithBundleIdentifier API will let u know the output. Thanks, Palav On 5/24/08, parag vibhute [EMAIL PROTECTED] wrote: I am launching my app through applet. So passing arguments as command line is only current solution for me. Thanks, Palav On 5/24/08, Andreas Mayer [EMAIL PROTECTED] wrote: Am 24.05.2008 um 08:08 Uhr schrieb Andrew Farmer: GUI applications generally do not take arguments - opened files are passed using Apple Events. Hence, Launch Services doesn't provide any way to pass arguments. You can use Apple Events yourself, though. See NSWorkspace's - launchAppWithBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifier : Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/parag.vibhute%40gmail.com This email sent to [EMAIL PROTECTED] -- There are many things in your life that will catch your eye but only a few will catch your heartpursue those'. -- There are many things in your life that will catch your eye but only a few will catch your heartpursue those'. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cleaning up a singleton
On 24/05/2008, at 3:48 PM, Andreas Mayer wrote: In case you use the notification, there is no need to expose anything. You just register a method of your singleton to receive the NSApplicationWillTerminateNotification and do your cleanup there. On Apple's developer website there are several example projects that make use of this. Here's one: http://developer.apple.com/samplecode/CapabilitiesSample/listing5.html You need only look at the -init and the -applicationWillTerminate: methods. Andreas Oh, that is awesome. Thanks for pointing it out. -- Sebastian Nowicki ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Core Data dynamic attributes and fetching
Hi all, I have a core data object graph using an SQLite store where several entities have an attribute containing a date (eg, birthDate). This is stored as a date type. I am currently implementing an NSPredicateEditor for building smart groups. Each smart group simply saves this predicate to an attribute and then fetches using that. The problem is that I want to offer to filter by ('days since birth' == 7), as well as (birthDate == 01/01/01). This is where I have hit a wall. I can't set a dynamic transient property for daysSinceBirth as these can't be used in fetch requests, and I can't convert the number of days to an absolute date as this loses the dynamic-calculation part of the number. I did think of using a transformable attribute to convert a second date field to an int, but then apparently this can't be used in a fetch request either. I suppose that I could use a placeholder segment of predicate which is replaced when used, but this seems a bit awkward and inelegant. Does anyone have any suggestions on how I could achieve this? Regards, Ben ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Change the Language of just one Application
Somewhere I have read (if my memory is not faulty) that it is possible to lauch an app with some arguments (or environment variables?) changing the preference order of languages. E.g. my preferred language is English, but I want to test the German localization of some app. Xcode allows me to set: Command-line arguments to pass to the program upon launch Environment variables to set before launching the program But what to set where? Another (related) problem: this works: open /Applications/TextEdit.app But this does not: open /Applications/TextEdit.app -NSOpen /tmp/a although recommended as more commonly used command-line argument by the Runtime Configuration Guidelines in Using Launch Arguments. Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSTextView without word wrap?
You're welcome, but I'd replace this: const CGFloat LargeNumberForText = 1.0e7; [[textView textContainer] setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)]; with [[textView textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)]; hey presto 1 less line of code! FLT_MAX is the largest representable floating point number. It *may* insulate you from processor differences, but someone would have to confirm to me that this could ever be a problem. Jon On 24 May 2008, at 02:35, David Carlisle wrote: Based on your kindly giving me a precise reference I was able to remove a few unnecessary statements from my awake from nib. It now reads as follows: - (void) awakeFromNib { const CGFloat LargeNumberForText = 1.0e7; [[textView textContainer] setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)]; [[textView textContainer] setWidthTracksTextView:NO]; [textView setHorizontallyResizable:YES]; } Thanks, DC On May 23, 2008, at 4:08 PM, Jonathan Dann wrote: Its in SMLViewMenuController.m line -(IBAction)lineWrapTextAction: Jon On 23 May 2008, at 22:58, David Carlisle wrote: Looks interesting. Thanks. DC On May 23, 2008, at 3:37 PM, Jonathan Dann wrote: You may also like to look at the source code to Smultron by Peter Borg. It's in there but I forget exactly. http://smultron.sourceforge.net/ Jon On 23 May 2008, at 21:55, David Carlisle wrote: I made some guesses at which statements to copy from BiScrollAspect.m and came up with the following awakeFromNib. I'm not sure which statements are the most relevant, and why, but it seems to do what I need. - (void) awakeFromNib { const CGFloat LargeNumberForText = 1.0e7; [[textView textContainer] setContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)]; [[textView textContainer] setWidthTracksTextView:NO]; [[textView textContainer] setHeightTracksTextView:NO]; [textView setAutoresizingMask:NSViewNotSizable]; [textView setMaxSize:NSMakeSize(LargeNumberForText, LargeNumberForText)]; [textView setHorizontallyResizable:YES]; [textView setVerticallyResizable:YES]; } On May 23, 2008, at 12:03 PM, Douglas Davidson wrote: On May 23, 2008, at 10:33 AM, David Carlisle wrote: I've spent the last few hours trying to create an NSTextView without word wrap. The BiScrollAspect.m file in the textSizingExample project file is no help at all. No help in that it doesn't do what you want, or no help in that you can't get it working in your app, or no help in some other way? Douglas Davidson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/j.p.dann%40gmail.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/davidcar1%40mstarmetro.net This email sent to [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: File's Owner
On 24 May 2008, at 05:39, Andreas Mayer wrote: I thought, maybe a picture would help: http://www.harmless.de/images/other/files_owner.png Exactly the picture I was about to draw. Johnny Lundy wrote: Saying it connects the nib to an object outside the nib sounds good, but what object is that? The object that loaded the NIB. What object is that? Whichever is passed when the NIB is loaded with [NSBundle loadNibNamed:owner:] e.g. NSApplication probably has code that looks like [NSBundle loadNibNamed:@MainMenu owner:self] You might have a piece of code that reads [NSBundle loadNibNamed:@InspectorWindows owner:inspectorController] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: File's Owner
On Sat, May 24, 2008 at 6:49 AM, Paul Sargent [EMAIL PROTECTED] wrote: On 24 May 2008, at 05:39, Andreas Mayer wrote: I thought, maybe a picture would help: http://www.harmless.de/images/other/files_owner.png Exactly the picture I was about to draw. Johnny Lundy wrote: Saying it connects the nib to an object outside the nib sounds good, but what object is that? The object that loaded the NIB. What object is that? Whichever is passed when the NIB is loaded with [NSBundle loadNibNamed:owner:] e.g. NSApplication probably has code that looks like [NSBundle loadNibNamed:@MainMenu owner:self] You might have a piece of code that reads [NSBundle loadNibNamed:@InspectorWindows owner:inspectorController] If your inspectorController is your own custom subclass of NSWindowController, it will make itself the nib's owner if you create it like this: MyInspectorController* ic = [[MyInspectorController alloc] initWithNibName:@ inspectorWindows]; sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Accessing colours in NSColorPanel swatch
Just for the archives, I found the solution to this on CocoaDev (which I had missed in my original search). Unfortunately it uses private methods, but I wrote an NSColorPanel category to access the swatch colours that should fail safely if the private methods are changed. I've added the category to the CocoaDev page here: http://www.cocoadev.com/index.pl?NSColorPanel Thanks anyway, Keith -- ORIGINAL MESSAGE -- I can't seem to find anything on this in the docs for NSColorPanel, NSColorList, or the working with colors documentation, but is there any way to access the user-defined list of colours in NSColorPanel? I mean the custom colours that the user drags into the swatch at the bottom of the colour panel for frequent use. I would like to provide a contextual menu in my application that makes these colours immediately available to the user, so that the user doesn't always have to open the colour panel to access the colours he or she has defined. Maybe I'm missing something obvious, but I would be very grateful for a point in the right direction. Many thanks in advance and all the best, Keith ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSURLConnection canHandleRequest: succeeds even with no network
On Sat, May 24, 2008 at 2:11 AM, Mike [EMAIL PROTECTED] wrote: Why does [ NSURLConnection canHandleRequest: ] return YES even if I turn off all my network connections? I thought this method was supposed to be used for preflighting connection requests? From what I gather, the preflight referred to in the docs is just a check to see if a protocol class is registered to handle the scheme (http:, file:, etc.). That is, it tells you if the proper machinery is in place to *attempt* the connection, not whether the attempt will succeed or not. It allows you to distinguish between I don't grok gopher and actual network-layer errors. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to tell if iTunes is running.
Thanks I am using this iTunesIsOpen = NO; [iTunesLMenu setTitle: NSLocalizedString(@Launch iTunes,@)]; NSArray *lApplications = [[NSWorkspace sharedWorkspace] launchedApplications]; int a; for (a=0; a[lApplications count]; a++) { NSDictionary *applicationD = [lApplications objectAtIndex:a]; if ([[applicationD objectForKey:@NSApplicationName] isEqualToString:@iTunes]) { iTunesIsOpen = YES; [iTunesLMenu setTitle: NSLocalizedString(@Quit iTunes,@)]; } } On May 23, 2008, at 5:07 PM, Nick Zitzmann wrote: On May 23, 2008, at 4:01 PM, Mr. Gecko wrote: How can I tell if iTunes is running with cocoa. In this particular case, you should be able to get that information using -[NSWorkspace launchedApplications]... Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quit iTunes
On 24 maj 2008, at 17.49, Mr. Gecko wrote: How would I quit iTunes. There is a way to launch it with NSWorkspace but how about quit? ___ Send a quit AppleEvent -- Home is not where you are born, but where your heart finds peace - Tommy Nordgren, The dying old crone [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quit iTunes
On May 24, 2008, at 12:33 PM, Mr. Gecko wrote: How would I do that? I have been looking for a while and I found aevtquit but I can't find out how to send. Read the documentation: http://developer.apple.com/documentation/AppleScript/Conceptual/AppleEvents/intro_aepg/chapter_1_section_1.html Oddly enough, there's a section called, Creating Sending Apple Events that has some code examples ... -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSWindow CoreAnimation Delegate not being called
Hi all, I've been playing with CA and I tried to set up one my objects as the delegate for the frame change animation for an NSWindow by using the following code: CABasicAnimation* anim = [window animationForKey:@frame]; anim.delegate = self; [[window animator] setFrame:NSMakeRect(400, 500, 500, 500) display:YES]; Using this, the window correctly animates but the delegate methods (namely animationDidStop:finished: and animationDidStart:) for the CAAnimation do not get called. When I use the exact same piece of code for setting the delegate of view animations, the delegates do get called. Thanks, M ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quit iTunes
Mr. Gecko wrote: How would I quit iTunes. There is a way to launch it with NSWorkspace but how about quit? Send a quit AppleEvent How would I do that? I have been looking for a while and I found aevtquit but I can't find out how to send. Example: #include Carbon/Carbon.h OSStatus QuitApplication(char *bundleID) { AppleEvent evt, res; OSStatus err; err = AEBuildAppleEvent(kCoreEventClass, kAEQuitApplication, typeApplicationBundleID, bundleID, strlen(bundleID), kAutoGenerateReturnID, kAnyTransactionID, evt, NULL, ); if (err == noErr) { err = AESendMessage(evt, res, kAENoReply, kAEDefaultTimeout); AEDisposeDesc(evt); } return err; } int main (int argc, const char * argv[]) { return QuitApplication(com.apple.itunes); } For anything more complex, use a high-level bridge (e.g. see my sig). HTH has -- Control AppleScriptable applications from Python, Ruby and ObjC: http://appscript.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Quit iTunes
That is slow because it has to compile. but if I can't get this apple event to work than I might do that On May 24, 2008, at 2:23 PM, Tommy Nordgren wrote: On 24 maj 2008, at 18.33, Mr. Gecko wrote: How would I do that? NSAppleScript * script = [[[NSAppleScript alloc] initWithSource:@tell application \iTunes\ \n quit \nend tell] autoRelease]; [script executeAndReturnError: nil]; I have been looking for a while and I found aevtquit but I can't find out how to send. On May 24, 2008, at 11:13 AM, Tommy Nordgren wrote: On 24 maj 2008, at 17.49, Mr. Gecko wrote: How would I quit iTunes. There is a way to launch it with NSWorkspace but how about quit? ___ Send a quit AppleEvent -- Home is not where you are born, but where your heart finds peace - Tommy Nordgren, The dying old crone [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se This email sent to [EMAIL PROTECTED] -- Skinheads are so tired of immigration, that they are going to move to a country that don't accept immigrants! Tommy Nordgren [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to tell if iTunes is running.
On 24.05.2008, at 21:05, Steve Christensen wrote: Would something like this work better? It should deal with localization or if the user renames iTunes for some reason. For third party software you'd be right - Apple does not localize the names of iTunes / iPhoto / iDVD (browse through the *.jproj/ infoPlist.strings) and AFIAK does not handle renamed or moved variants in their updaters, so people renamaing iApps face trouble anyway... Best regards, Tom_E ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to tell if iTunes is running.
On 24 May '08, at 12:05 PM, Steve Christensen wrote: Would something like this work better? It should deal with localization or if the user renames iTunes for some reason. ... if ([[applicationD objectForKey:@NSApplicationPath] isEqualToString:iTunesPath]) It would be simpler just to use the NSApplicationBundleIdentifier key, comparing it with com.apple.iTunes. —Jens smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to tell if iTunes is running.
My version wasn't about using the path for something else; it was only about providing a method that doesn't care what the iTunes application is called. For example, if someone were to rename it iTunes 7.6.2, then your version would stop working. However, as Thomas Engelmeier pointed out in a separate message, Apple doesn't currently localize the names of its iApps so you're probably safe. On May 24, 2008, at 12:17 PM, Mr. Gecko wrote: because I do not need the path for what I am doing. On May 24, 2008, at 2:05 PM, Steve Christensen wrote: Would something like this work better? It should deal with localization or if the user renames iTunes for some reason. iTunesIsOpen = NO; NSWorkspace* workspace = [NSWorkspace sharedWorkspace]; NSString* iTunesPath = [workspace absolutePathForAppBundleWithIdentifier:@com.apple.iTunes]; NSArray* lApplications = [workspace launchedApplications]; int lAppsCount = [lApplications count]; int a; for (a = 0; a lAppsCount; a++) { NSDictionary* applicationD = [lApplications objectAtIndex:a]; if ([[applicationD objectForKey:@NSApplicationPath] isEqualToString:iTunesPath]) { iTunesIsOpen = YES; break; } } [iTunesLMenu setTitle: NSLocalizedString(iTunesIsOpen ? @Quit iTunes : @Launch iTunes,@)]; On May 24, 2008, at 8:29 AM, Mr. Gecko wrote: Thanks I am using this iTunesIsOpen = NO; [iTunesLMenu setTitle: NSLocalizedString(@Launch iTunes,@)]; NSArray *lApplications = [[NSWorkspace sharedWorkspace] launchedApplications]; int a; for (a=0; a[lApplications count]; a++) { NSDictionary *applicationD = [lApplications objectAtIndex:a]; if ([[applicationD objectForKey:@NSApplicationName] isEqualToString:@iTunes]) { iTunesIsOpen = YES; [iTunesLMenu setTitle: NSLocalizedString(@Quit iTunes,@)]; } } On May 23, 2008, at 5:07 PM, Nick Zitzmann wrote: On May 23, 2008, at 4:01 PM, Mr. Gecko wrote: How can I tell if iTunes is running with cocoa. In this particular case, you should be able to get that information using -[NSWorkspace launchedApplications]... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to tell if iTunes is running.
On May 24, 2008, at 2:11 PM, Jens Alfke wrote: On 24 May '08, at 12:05 PM, Steve Christensen wrote: Would something like this work better? It should deal with localization or if the user renames iTunes for some reason. ... if ([[applicationD objectForKey:@NSApplicationPath] isEqualToString:iTunesPath]) It would be simpler just to use the NSApplicationBundleIdentifier key, comparing it with com.apple.iTunes. I didn't see that in the headers but it is in the docs. Yes, that'd work better. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: File's Owner
I dunno. Your book seems to be one of the few, if not the only, that is not on my bookshelf. If you email me your page on File's Owner, I can give feedback. On May 23, 2008, at 9:59 PM, [EMAIL PROTECTED] wrote: I despair that I am unable to adequately explain the concept and utility of File's Owner to you. This disturbs me greatly because I have written a book about Cocoa Programming, and I explained File's Owner in that book. I fear that I have failed. If I can't explain this concept to a very learned programmer, how can I explain it to a true novice. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How many times will a sub-classed NSView be instantiated in a simple Cocoa App?
On May 24, 2008, at 6:09 PM, Graham Reitz wrote: Awesome! Thanks Nathan. That makes a lot more sense to me. Just set the class of the Custom View. What do you specifically mean by 'set the class'? In IB select the view then select the Identity Inspector (cmd-6 or the icon with the i in a circle) and set the Class Identity to the class you created in Xcode. I think this is also what you were referring to in step 4 (unless I misunderstood you). 4) Name the Custom View and Object to the same class name --Nathan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSTextField in NSCollectionView aborts editing without notice, solved
I have an NSTextField in an NSCollectionView. If I type in a change to the NSTextField, then without hitting tab or clicking elsewhere in the NSCollectionView I click on a popup menu in the window, the NSTextField aborts the edit and loses the information without any kind of notice being given to the NSTextField. I solved the problem by subclassing NSTextFieldCell and overriding the method endEditing, passing it up to the superclass after first sending an emergency message to the window controller, along with a copy of the NSTextField, indicating it needs to grab the edited string out of the NSTextField because the information is about to be lost. I tried monitoring resignsFirstResponder. I can then click on the NSTextFields in the NSCollectionView and get resignsFirstResponder messages as expected. If I click on an NSTextField and then hit a key to begin an edit, the sequence of messages is as follows: NSTextField gets the message: textShouldBeginEditing The NSTextField delegate, which is an NSCollectionViewItem, gets the message: control:textShouldBeginEditing NSTextField gets the message: textDidBeginEditing The NSTextField delegate gets the message: control:textDidBeginEditing After I type in some text, if I were to click on the popup as described, neither NSTextField nor its delegate gets any of the text did/should end editing messages which correspond with the above messages. FWIW, if rather than clicking on the popup menu I click on another text field, the NSTextField gets both of the textShouldEndEditing messages, but not any textDidEndEditing messages. After those messages, it gets the expected resignsFirstResponder message. If after I click on the popup menu I click on another NSTextField, I do get a resignsFirstResponder message from an NSTextField, but by that time the information in the field I had edited has already been lost. So is this a bug? Is it a feature? Am I missing something? Has someone already found an easier way of dealing with this? If someone else is already wondering about this problem, then this is the way I solved it. DC ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSWindow CoreAnimation Delegate not being called
I'm no core animation expert, but. This... // self is an NSWindow instance CAAnimation *anim = [CABasicAnimation animation]; [anim setDelegate:self]; [self setAnimations:[NSDictionary dictionaryWithObject:anim forKey:@frame]]; [[self animator] setFrame:NSMakeRect(0,0,0,0) display:YES]; ... works perfectly in my app, calling the delegate methods and all. All other things being equal, the only difference I see is that you use [window animationForKey:@frame] whereas I create a new animation and then add it to the window with [window setAnimations:...]. My *guess* would be that maybe windows don't instantiate default animations until they're needed, whereas frames instantiate them at init. So when you call [window animationForKey:@frame] you're getting nil back. But that's just a guess. I really don't know enough about it. Bug? Feature? I don't know. But this could be a workaround, anyway. -Pete On May 24, 2008, at 7:11 AM, Milen Dzhumerov wrote: Hi all, I've been playing with CA and I tried to set up one my objects as the delegate for the frame change animation for an NSWindow by using the following code: CABasicAnimation* anim = [window animationForKey:@frame]; anim.delegate = self; [[window animator] setFrame:NSMakeRect(400, 500, 500, 500) display:YES]; Using this, the window correctly animates but the delegate methods (namely animationDidStop:finished: and animationDidStart:) for the CAAnimation do not get called. When I use the exact same piece of code for setting the delegate of view animations, the delegates do get called. Thanks, M ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]