NSArrayController's selectedIndexes
When I observe an NSArrayController's selectedIndexes key like so: - (void)awakeFromNib { [arrayController addObserver:self forKeyPath:@selectionIndexes options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { NSLog(@change: %@, change); } I'm never seeing the old and new indexes. I always see output like: 2008-08-09 00:14:04.513 test[12498:10b] change: { kind = 1; new = null; old = null; } [arrayController selectedIndexes] gives the correct new value. A table view is bound to the array controller in a typical configuration (selectedIndexes is bound to the array controller). Any ideas? Ryan ___ 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: NSArrayController's selectedIndexes
Never mind, the (Missing) KVO notification old and new values section on mmalc's Cocoa Bindings Examples and Hints confirmed that this is a bug. It mentions that this won't be fixed for the forseeable future... could someone elaborate as to why? Ryan On Aug 9, 2008, at 12:24 AM, Ryan Brown wrote: When I observe an NSArrayController's selectedIndexes key like so: - (void)awakeFromNib { [arrayController addObserver:self forKeyPath:@selectionIndexes options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { NSLog(@change: %@, change); } I'm never seeing the old and new indexes. I always see output like: 2008-08-09 00:14:04.513 test[12498:10b] change: { kind = 1; new = null; old = null; } [arrayController selectedIndexes] gives the correct new value. A table view is bound to the array controller in a typical configuration (selectedIndexes is bound to the array controller). Any ideas? Ryan ___ 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/ryan%40wabdo.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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Dragging broken symlinks
On 9 Aug 2008, at 12:27, Ken Thomases wrote: On Aug 8, 2008, at 11:26 PM, Gerriet M. Denkmann wrote: I have an app which can open symlinks (not the thing the symlink points to). Done via [ openPanel setResolvesAliases: NO ]; But when I drag a symlink to the icon of my app in the dock, - (BOOL)application:(NSApplication *)theApplication openFile: (NSString *)filename will have filename = content of symlink (or alias). And in case of a broken symlink nothing happens at all. How can I open broken symlinks by dragging? There's a good chance that you can't. It may be that Launch Services, which is used by the Dock or the Finder to pass the open- document request to your application in response to your drag operation, has already resolved the symlink (or attempted to do so). You could try installing a handler for the 'odoc' Apple Event to see if you can override Cocoa's handling. I don't know if the framework will let you do that. Did that. But the 'odoc' event I get contains an 'alis' which contains the content of the symlink. And no 'odoc' at all for a broken symlink. So obviously the Dock (or whoever) already has done its evel magic. You might have to build a Carbon application to test the possibility at a low level, with the Cocoa framework removed from the equation. If it's not possible there, it's almost certainly not possible in a Cocoa app. Using the DTSCarbonShell sample code as a starting point, it should be fairly easy to build such a test. Well, this is more than I am prepared to invest. I just added the non- draggable nature of symlinks and aliases to the list of known bugs and will leave it at that. 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]
Using @selector()
Hi guys, I'm a newbie and I'm reading a book which shows the two different option to link programmatically a control to an action: SEL mySelector; mySelector = @selector(methodName:); [myButton setAction:mySelector]; OR SEL mySelector; mySelector = NSSelectorFromString(@methodName:); [myButton setTarget:someObjectWithTheMethod]; [myButton setAction:mySelector]; On my test, the first syntax doesn't seem to work. This is my implementation. - (void)awakeFromNib { NSLog(@awakeFromNib); SEL mySelector; mySelector = @selector(sayIt:); [sayItButton setAction:mySelector]; } If I do the other syntax: - (void)awakeFromNib { NSLog(@awakeFromNib); SEL mySelector; mySelector = NSSelectorFromString(@sayIt:); [sayItButton setTarget:self]; [sayItButton setAction:mySelector]; } Works. The sayIt method is in the same class than the awakeFromNib of course. Any ideas? Thanks, chr ___ 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 whether an executable supports GC?
You can also create your own helper tool compiled with GC support and, that just preflight the bundle you pass as argument and return the result. It's a little more works, but it's cleaner too. Le 9 août 08 à 03:32, André Pang a écrit : On 08/08/2008, at 3:18 PM, Chris Suter wrote: You want to look at the __image_info section in the __OBJC segment: struct objc_image_info { uint32_tversion;// initially 0 uint32_tflags; }; #define OBJC_IMAGE_SUPPORTS_GC 2 #define OBJC_IMAGE_GC_ONLY 4 Thanks for the heads-up Chris! Thanks to your tip, I settled for a rather cheap solution that works just fine for me: /usr/bin/otool -o $PATH | grep -q -2 '__OBJC.__image_info' | grep GC :) I'm not 100% sure that otool's installed without the BSD subsystem being available, but I think that's mandatory now with Leopard. The GC check is just used for displaying some extra informative text in a sheet (which plugins aren't GC supported), so if anything fails, it's not a disaster. I figured it'd be easier than trying to find some libraries to read in the Mach-O format... considering the tininess of the problem, it was far too much effort! -- % Andre Pang : trust.in.love.to.save http://www.algorithm.com.au/ ___ 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/devlists%40shadowlab.org 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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Using @selector()
Le 9 août 08 à 10:34, Christian Giordano a écrit : Hi guys, I'm a newbie and I'm reading a book which shows the two different option to link programmatically a control to an action: SEL mySelector; mySelector = @selector(methodName:); [myButton setAction:mySelector]; OR SEL mySelector; mySelector = NSSelectorFromString(@methodName:); [myButton setTarget:someObjectWithTheMethod]; [myButton setAction:mySelector]; On my test, the first syntax doesn't seem to work. This is my implementation. - (void)awakeFromNib { NSLog(@awakeFromNib); SEL mySelector; mySelector = @selector(sayIt:); [sayItButton setAction:mySelector]; } If I do the other syntax: - (void)awakeFromNib { NSLog(@awakeFromNib); SEL mySelector; mySelector = NSSelectorFromString(@sayIt:); [sayItButton setTarget:self]; [sayItButton setAction:mySelector]; } Works. The sayIt method is in the same class than the awakeFromNib of course. Any ideas? Why you do not set the target in the first method ? ___ 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: Problem with friend function and gcc 4.2 with objective-c++
Am 08.08.2008 um 00:09 schrieb Ken Worley: Hi all, I'm using Xcode 3.1 and just switched to gcc 4.2 from 4.0, but I've run into a problem with friend functions when compiling in objective- c++. I contrived an example that illustrates the problem: [...] This project builds fine using gcc 4.0, but when I switch the compiler setting to use gcc 4.2, I get the errors listed below. Any clues would certainly be appreciated if I'm doing something wrong. If not, I guess I'll file a bug... Here's main.m: #import Cocoa/Cocoa.h class test1 { public: friend test1* newtest1(int x) { test1* anobj = new test1(); anobj-finishinit(x); return anobj; } [...] }; int main(int argc, char *argv[]) { test1* tobj = newtest1(5); delete tobj; return NSApplicationMain(argc, (const char **) argv); } friend != static, and even then this probably would not be valid semantics. test1* tobj = newtest1(5); has nothing to do with test1::newtest1( int ) or aTest1Instance-newtest1( int ) ___ 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: Using @selector()
yep, it works with that :) I presume it is an error in the book. Personally I thought that passing the method not as string it would have recognized the scope (target) automatically. Thanks a lot, chr On Sat, Aug 9, 2008 at 9:45 AM, Jean-Daniel Dupas [EMAIL PROTECTED] wrote: Le 9 août 08 à 10:34, Christian Giordano a écrit : Hi guys, I'm a newbie and I'm reading a book which shows the two different option to link programmatically a control to an action: SEL mySelector; mySelector = @selector(methodName:); [myButton setAction:mySelector]; OR SEL mySelector; mySelector = NSSelectorFromString(@methodName:); [myButton setTarget:someObjectWithTheMethod]; [myButton setAction:mySelector]; On my test, the first syntax doesn't seem to work. This is my implementation. - (void)awakeFromNib { NSLog(@awakeFromNib); SEL mySelector; mySelector = @selector(sayIt:); [sayItButton setAction:mySelector]; } If I do the other syntax: - (void)awakeFromNib { NSLog(@awakeFromNib); SEL mySelector; mySelector = NSSelectorFromString(@sayIt:); [sayItButton setTarget:self]; [sayItButton setAction:mySelector]; } Works. The sayIt method is in the same class than the awakeFromNib of course. Any ideas? Why you do not set the target in the first method ? ___ 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: Using @selector()
On 09.08.2008, at 11:23, Christian Giordano wrote: yep, it works with that :) I presume it is an error in the book. Probably. Or they hooked up the target in IB before that. Personally I thought that passing the method not as string it would have recognized the scope (target) automatically. Now you know better. FWIW, it helps me to think that @selector() is like referencing a function pointer directly, while NSSelectorFromString() is like using CFBundle or dyld of CFM's FindSymbol(), or whatever API you've used before to look up functions at runtime. If you've used one at runtime ... which I guess only compiler and plug-in nuts like me do, so forget what I said ... :-) Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Fri, Aug 8, 2008 at 6:48 PM, Mark Allan [EMAIL PROTECTED] wrote: On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan [EMAIL PROTECTED] said: Hi all, Before I file a bug report against this, I just thought I'd check I'm not being monumentally stupid first! I'm trying to animate my app's Dock icon, which works fine and looks great, but unfortunately, it appears to leak memory like crazy. Every time I call [NSApp setApplicationIconImage:(NSImage *)] and pass it pointer to an existing image, it leaks more memory. Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; I think you'll find that solves the problem. Sorry, I should have said in my original message that I'd already tried that, and the autorelease pool did solve the problem. It's just that doing this hundreds (possibly thousands) of times until my process is finished seems horribly inefficient. Do you know if it's actually a leak or if it's like that by design? http://www.mikeash.com/?page=pyblog/autorelease-is-fast.html In short, the cost of creating and destroying an NSAutoreleasePool is about the same as the cost of creating and destroying two NSObjects. It is extremely rare that the cost of a pool is noticeable against the other stuff that your code is doing. 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]
[MEET] Syracuse Area CocoaHeads
Folks, Just a small note that we will be meeting a couple of days earlier than the usual time. Plan to get together with us at the Fayetteville Free Library on this Tuesday August 12th at 7PM EST. See http://fruitstandsoftware.com/CocoaHeads/ for maps and more info. Regards, Michael ___ 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: Problem with friend function and gcc 4.2 with objective-c++
On Sat, Aug 9, 2008 at 2:20 AM, Thomas Engelmeier [EMAIL PROTECTED] wrote: Am 08.08.2008 um 00:09 schrieb Ken Worley: Hi all, I'm using Xcode 3.1 and just switched to gcc 4.2 from 4.0, but I've run into a problem with friend functions when compiling in objective-c++. I contrived an example that illustrates the problem: [...] This project builds fine using gcc 4.0, but when I switch the compiler setting to use gcc 4.2, I get the errors listed below. Any clues would certainly be appreciated if I'm doing something wrong. If not, I guess I'll file a bug... Here's main.m: #import Cocoa/Cocoa.h class test1 { public: friend test1* newtest1(int x) { test1* anobj = new test1(); anobj-finishinit(x); return anobj; } [...] }; int main(int argc, char *argv[]) { test1* tobj = newtest1(5); delete tobj; return NSApplicationMain(argc, (const char **) argv); } friend != static, and even then this probably would not be valid semantics. test1* tobj = newtest1(5); has nothing to do with test1::newtest1( int ) or aTest1Instance-newtest1( int ) I believe that you are incorrect. This is a perfectly valid way of defining friend functions in C++. Defined this way, newtest1 is a global function (i.e. it is not scoped to test) that is allowed to access the private/protected parts of test1 instances. From the C++ standard (11.4 paragraph 5): A function can be defined in a friend declaration of a class if and only if the class is a non-local class (9.8), the function name is unqualified, and the function has namespace scope. [Example: class M { friend void f() { } //definition of globalf, a friend ofM, //not the definition of a member function }; —end example] Such a function is implicitlyinline. Afriendfunction defined in a class is in the (lexical) scope of the class in which it is defined. If I were the original poster, I would file a bug. -- Clark S. Cox III [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: Key Binding action methods not declared in public headers
On Aug 8, 2008, at 4:44 PM, Douglas Davidson wrote: The right thing to do would be to file a bug requesting publication of those methods, and to inquire in the bug whether it would be safe to override them regardless of their current status. Douglas Davidson Thanks, Douglas. bug #6138065 ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Fri, 8 Aug 2008 23:53:08 +0100, Mark Allan [EMAIL PROTECTED] said: On Fri, Aug 8, 2008 at 9:02 AM, Matt Neuburg [EMAIL PROTECTED] wrote: On Thu, 7 Aug 2008 20:14:04 +0100, Mark Allan [EMAIL PROTECTED] said: Hi all, Before I file a bug report against this, I just thought I'd check I'm not being monumentally stupid first! I'm trying to animate my app's Dock icon, which works fine and looks great, but unfortunately, it appears to leak memory like crazy. Every time I call [NSApp setApplicationIconImage:(NSImage *)] and pass it pointer to an existing image, it leaks more memory. Wrap each call to setApplicationIconImage in an autorelease pool creation and release, like this: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [NSApp setApplicationIconImage: whatever]; [pool release]; I think you'll find that solves the problem. Sorry, I should have said in my original message that I'd already tried that, and the autorelease pool did solve the problem. Yes, that sure would have been a nice thing to do. At 6:24 pm -0400 08/08/2008, Sumner Trammell wrote: Is the need for the autorelease pool because of the use of setApplicationIconImage, or because of the array that is being used in conjunction with setApplicationIconImage? Your idea of removing the array from the equation also solves the leak and I suspect is more efficient than creating and releasing a tonne of autorelease pools. Really? Can you explain what removing the array from the equation has to do with the memory behavior you're seeing? m. -- matt neuburg, phd = [EMAIL PROTECTED], http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! One of the 2007 MacTech Top 25: http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide - Second Edition! http://www.amazon.com/gp/product/0596102119 ___ 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: Problem with friend function and gcc 4.2 with
FWIW, it does in fact compile in 4.2 (and in 4.0) when formatted as you suggest. I still believe the original format is correct and that 4.2 is the version with the bug. The info Clark Cox pointed out seems to support that. In any case, a bug has been filed, so I'll know Apple's point of view eventually :) Thanks for the input (and thanks also to Clark and Thomas for responding). rdar://6135771 Ken On Aug 8, 2008, at 10:42 PM, Roni Music wrote: I'm not a C++ expert but your code below should not compile (as I see it) You should declare the friend function inside the class: class test1 { public: friend test1* newtest1(int x); /* the function newtest1() is now a friend to test1 class and may access private member variables and functions such as finishinit() */ snip }; then define the function outside the class: test1* newtest1(int x) { test1* anobj = new test1(); anobj-finishinit(x); return anobj; } So if you code worked with gcc 4.0 and not gcc 4.2, then it seems gcc 4.2 now works according to the C++ standard and gcc 4.0 did not Rolf Message: 10 Date: Fri, 8 Aug 2008 16:41:42 -0600 From: Ken Worley [EMAIL PROTECTED] Subject: Re: Problem with friend function and gcc 4.2 with objective-c++ To: cocoa-dev cocoa-dev cocoa-dev@lists.apple.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Hmmm, no response as of yet. I went ahead and submitted a bug against Xcode: rdar://6135771 We'll see what happens. Ken On Aug 7, 2008, at 4:09 PM, Ken Worley wrote: Hi all, I'm using Xcode 3.1 and just switched to gcc 4.2 from 4.0, but I've run into a problem with friend functions when compiling in objective- c++. I contrived an example that illustrates the problem: 1. Created new Cocoa project 2. Forced compilation of all files to use objective-c++ 3. Changed content of main.m to below... This project builds fine using gcc 4.0, but when I switch the compiler setting to use gcc 4.2, I get the errors listed below. Any clues would certainly be appreciated if I'm doing something wrong. If not, I guess I'll file a bug... Here's main.m: #import Cocoa/Cocoa.h class test1 { public: friend test1* newtest1(int x) { test1* anobj = new test1(); anobj-finishinit(x); return anobj; } virtual ~test1() { } private: int avalue; test1() { avalue = 0; } void finishinit(int x) { avalue = x; } }; int main(int argc, char *argv[]) { test1* tobj = newtest1(5); delete tobj; return NSApplicationMain(argc, (const char **) argv); } Here's the build log: Building target Untitled of project Untitled with configuration Debug - (1 error) cd /Users/ken/Desktop/Untitled /Xcode3.1/Developer/usr/bin/gcc-4.2 -x objective-c++ -arch i386 - fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Xcode3.1/Developer/ SDKs/MacOSX10.5.sdk -mfix-and-continue -fvisibility-inlines-hidden - mmacosx-version-min=10.5 -gdwarf-2 -iquote /Users/ken/Desktop/ Untitled/build/Untitled.build/Debug/Untitled.build/Untitled- generated-files.hmap -I/Users/ken/Desktop/Untitled/build/ Untitled.build/Debug/Untitled.build/Untitled-own-target-headers.hmap -I/Users/ken/Desktop/Untitled/build/Untitled.build/Debug/ Untitled.build/Untitled-all-target-headers.hmap -iquote /Users/ken/ Desktop/Untitled/build/Untitled.build/Debug/Untitled.build/Untitled- project-headers.hmap -F/Users/ken/Desktop/Untitled/build/Debug -I/ Users/ken/Desktop/Untitled/build/Debug/include -I/Users/ken/Desktop/ Untitled/build/Untitled.build/Debug/Untitled.build/DerivedSources - include /var/folders/JE/JEJ3RSLHE9uIDGjXTRTisTI/-Caches-/ com.apple.Xcode.501/SharedPrecompiledHeaders/Untitled_Prefix- brblicjbwwpqhfahflncgqpvarno/Untitled_Prefix.pch -c /Users/ken/ Desktop/Untitled/main.m -o /Users/ken/Desktop/Untitled/build/ Untitled.build/Debug/Untitled.build/Objects-normal/i386/main.o /Users/ken/Desktop/Untitled/main.m: In function 'int main(int, char**)': /Users/ken/Desktop/Untitled/main.m:43: error: 'newtest1' was not declared in this scope /Users/ken/Desktop/Untitled/main.m:43: error: 'newtest1' was not declared in this scope Build failed (1 error) Thanks, Ken -- Ken Worley Software Engineer, Tiberius, Inc. ___ 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/cocoadev%40tiberiusinc.com This email sent to [EMAIL PROTECTED] -- Ken Worley Software Engineer, Tiberius, Inc. -- Ken Worley Software Engineer, Tiberius, Inc. ___ 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
Custom URL Handling
I want to implement a custom URL scheme (such that myscheme:whatever will open my app and somehow pass the URL as a parameter). I've been looking around for information on how to do that, and I'm getting mixed messages. The Info.plist documentation is very clear, and I've got the keys all set up the right way such that my app opens when a URL of my custom scheme is opened. However, I'm not sure how to find out what URL was opened. I see some implementations use -[NSAppleEventManager setEventHandler:andSelector:forEventClass:andEventID:]; with kInternetEventClass and kAEGetURL, and they implement a method (passed into the selector): - (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent. In other places, I see LSSetDefaultHandlerForURLScheme, and other LS* stuff. Another thing I've seen is adding a script suite and using performDefaultImplementation and [self directParameter] to get the URL. So, I need to know what the right way to do this is. I don't see any specific information about this in Apple's documentation. Thanks in advance. ___ 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: Does [NSApp setApplicationIconImage] leak memory?
Your idea of removing the array from the equation also solves the leak and I suspect is more efficient than creating and releasing a tonne of autorelease pools. Really? Can you explain what removing the array from the equation has to do with the memory behavior you're seeing? m. No, sadly I can't explain it, but it does prevent the memory from leaking. I changed my initialiser calls from NSArray *imageX = [[NSArray arrayWithObjects: [NSImage imageNamed:@menu_frame1], [NSImage imageNamed:@dock_frame1], nil] retain]; to NSImage *dockImageX = [[NSImage imageNamed:@dock_frame1] retain]; and for each frame of the animation, I'm passing that NSImage directly to the [NSApp setApplicationIconImage:theNewImage] call. Even without the autorelease pools, the app's memory usage now stays constant after the first animation of all 8 frames. I fail to see how [NSApp setApplicationIconImage:theNewImage]; is any different to [NSApp setApplicationIconImage:[theNewImage objectAtIndex:1]] but it obviously does function differently. Mark ___ 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: Custom URL Handling
On 09.08.2008, at 22:53, Jacob Bandes-Storch wrote: I want to implement a custom URL scheme (such that myscheme:whatever will open my app and somehow pass the URL as a parameter). I've been looking around for information on how to do that, and I'm getting mixed messages. I'm not a specialist, but I'll provide what I think is correct: The Info.plist documentation is very clear, and I've got the keys all set up the right way such that my app opens when a URL of my custom scheme is opened. However, I'm not sure how to find out what URL was opened. I see some implementations use -[NSAppleEventManager setEventHandler:andSelector:forEventClass:andEventID:]; with kInternetEventClass and kAEGetURL, and they implement a method (passed into the selector): - (void)handleURLEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent. (...) Another thing I've seen is adding a script suite and using performDefaultImplementation and [self directParameter] to get the URL. When a URL is opened, an Apple Event of kInternetEventClass/ kAEGetURL is sent, containing the URL. If you want to handle the URL, you'll need to catch this somehow. Cocoa AppleScript support is fairly new (I think 10.2 or 10.3 or thereabouts). So, depending on what system version your app has as its minimal requirement, you'll either use NSAppleEventManager (which is the older class, AFAIK) or the script suite. Instead of performDefaultImplementation, I think you could also just create an NSScriptCommand or whatever the class was called. Whatever feels cleaner to you. In other places, I see LSSetDefaultHandlerForURLScheme, and other LS* stuff. You'll want to use the default handler thing if your scheme is likely to be shared with other apps. Like Safari, which lets you specify the application to use for handling RSS feeds, either itself or other apps, like NetNewsWire. These APIs let you explicitly set who handles a scheme. Specifying it in the Info.plist means the system decides who gets the URL, if there are several handlers. So, if this is a scheme only your app will use (i.e. x-myapp-license: or x-myapp- triggersoftwareupdate: or whatever), the Info.plist approach should be enough. Again, the different approaches may have different system requirements. So, I need to know what the right way to do this is. I don't see any specific information about this in Apple's documentation. Hope this helps a bit. If anyone knows better, please correct me. I haven't had to do that yet, that's just stuff I remember having read in places. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de ___ 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: Does [NSApp setApplicationIconImage] leak memory?
On Sat, Aug 9, 2008 at 2:46 PM, Mark Allan [EMAIL PROTECTED] wrote: I fail to see how [NSApp setApplicationIconImage:theNewImage]; is any different to [NSApp setApplicationIconImage:[theNewImage objectAtIndex:1]] but it obviously does function differently. Please post a complete code example that shows the original issue. I assure you the change that you stated that corrected the issue isn't the thing that corrected (of course you have only been posting partial code snippets and descriptions so we don't have the full context). -Shawn ___ 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]
I don't understand why this is leaking...
This code is leaking: - (void)saveItemExtensions:(id)sender { NSMutableString* itemExtensionsFilePath = [NSMutableString stringWithString:@~/Library/Preferences/MyApp/extensions.abc]; NSDictionary* extensions = [NSDictionary dictionaryWithDictionary: [itemDataSource itemExtensions]]; [itemExtensionsFilePath setString:[itemExtensionsFilePath stringByExpandingTildeInPath]]; [[NSArchiver archivedDataWithRootObject:extensions] itemExtensionsFilePath atomically: YES]; } - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeObject: string1]; [coder encodeObject: string2]; [coder encodeObject: string3]; [coder encodeObject: string4]; [coder encodeObject: string5]; [coder encodeObject: string6]; [coder encodeObject: string7]; [coder encodeObject: string8]; } According to MallocDebug, the leak is in the encodeWithCoder method. Things I've tried: 1 [coder encodeObject: [string1 autorelease]]; Which, of course, caused a crash 2 [coder encodeObject: [string1 copy]]; no diff 3 [coder encodeObject: [[string1 copy] autorelease]]; no diff 4 Drinking beer... Can anyone explain this to me? Tony ___ 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: I don't understand why this is leaking...
On Aug 9, 2008, at 4:48 PM, Cate Tony wrote: This code is leaking: - (void)saveItemExtensions:(id)sender { NSMutableString* itemExtensionsFilePath = [NSMutableString stringWithString:@~/Library/Preferences/MyApp/extensions.abc]; NSDictionary* extensions = [NSDictionary dictionaryWithDictionary: [itemDataSource itemExtensions]]; [itemExtensionsFilePath setString:[itemExtensionsFilePath stringByExpandingTildeInPath]]; [[NSArchiver archivedDataWithRootObject:extensions] itemExtensionsFilePath atomically: YES]; } - (void)encodeWithCoder:(NSCoder *)coder { [coder encodeObject: string1]; [coder encodeObject: string2]; [coder encodeObject: string3]; [coder encodeObject: string4]; [coder encodeObject: string5]; [coder encodeObject: string6]; [coder encodeObject: string7]; [coder encodeObject: string8]; } According to MallocDebug, the leak is in the encodeWithCoder method. Things I've tried: 1 [coder encodeObject: [string1 autorelease]]; Which, of course, caused a crash 2 [coder encodeObject: [string1 copy]]; no diff 3 [coder encodeObject: [[string1 copy] autorelease]]; no diff 4 Drinking beer... Can anyone explain this to me? Tony What is coder? It could be that coder is deferring the encoding (saving copies of string*), and then the coder itself is never getting released. Have Instruments make sure that the coder is actually going away after the encoding is done. Also check to make sure the encoded data is going away when it is no longer needed. Sometimes the leak isn't exactly where MallocDebug says the object was allocated: -retain increments the retain count as surly as -alloc. What do the individual string* histories look like in Instruments? Speaking of Instruments, could you give us (not the mailing list, I don't think it allows attachments, but you could email me separately) an instruments session to look at? It would greatly facilitate proceedings :) Also, why are you using non-keyed encoding? -encodeObject:forKey: is the preferred way of doing things nowadays... ___ 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/jjoonathan %40gmail.com 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: Custom URL Handling
It doesn't seem to make sense to use the script suite stuff to receive the URL event.. shouldn't it be used for scripting only? Or am I mistaken? On Aug 9, 2008, at 3:03 PM, Uli Kusterer wrote: I see some implementations use -[NSAppleEventManager setEventHandler:andSelector:forEventClass:andEventID:]; with kInternetEventClass and kAEGetURL, and they implement a method (passed into the selector): - (void)handleURLEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent. (...) Another thing I've seen is adding a script suite and using performDefaultImplementation and [self directParameter] to get the URL. When a URL is opened, an Apple Event of kInternetEventClass/ kAEGetURL is sent, containing the URL. If you want to handle the URL, you'll need to catch this somehow. Cocoa AppleScript support is fairly new (I think 10.2 or 10.3 or thereabouts). So, depending on what system version your app has as its minimal requirement, you'll either use NSAppleEventManager (which is the older class, AFAIK) or the script suite. Instead of performDefaultImplementation, I think you could also just create an NSScriptCommand or whatever the class was called. Whatever feels cleaner to you. ___ 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: Custom URL Handling
On 10.08.2008, at 01:50, Jacob Bandes-Storch wrote: It doesn't seem to make sense to use the script suite stuff to receive the URL event.. shouldn't it be used for scripting only? Or am I mistaken? Apple Events are simply a means for applications to communicate. Just like you can use AppleScript to tell an application to open a file (which sends an 'aevt'/'open' Apple Event), you can tell it to open a URL. So, using the scripting stuff not only implements the handler in a nice, object-oriented way, it also allows users to use scripting languages to achieve the same. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de ___ 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: generating a moveRight
OOps! Sorry folks... tricky answer, that was... nil ;-) J. On 9-Aug-08, at 5:30 PM, James Maxwell wrote: I'm trying to programmatically generate a -moveRight: action, using sendAction:to:from. The action for this is, of course, pressing the right arrow key, but how do I fake that programmatically? Basically, I'm wondering how to define the sender for the from: in -sendAction:to:from:? thanks, J. ___ 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/jbmaxwell%40rubato-music.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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Challenge 18 in Hillegass Book
On Aug 8, 2008, at 6:40 PM, Graham Cox wrote: So there needs to be a connection between model, controller and view that allows you to communicate freely back and forth. For now you could just use the view as the model, unless you are really keen to explore MVC at this point rather than just complete the exercise. I think that's where I'm unclear. Making the Document class aware of the view is easy enough with an IBOutlet. But how to properly make the view aware of the document I'm unsure of. Thanks to all for the responses, they've been helpful! -J ___ 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]
Controlling line-breaking in a text view
Hi, I'm having trouble figuring out how to make the text system not break words that begin with a '/', such as paths, when wrapping. Let's say that we're laying out the following line of text: = Normally, you should never delete /Applications = I want '/Applications' to stay intact when wrapping. By default, the text system wraps it the following way: = Normally, you should never delete / Applications = I'd like it to look like this: = Normally, you should never delete /Applications = After much searching, the best solution I've come up with so far is a subclass of NSATSTypesetter with the following method implementation in it: - (BOOL)shouldBreakLineByWordBeforeCharacterAtIndex: (NSUInteger)charIndex { NSString *string = [[[self layoutManager] textStorage] string]; if (charIndex = 1) { NSTextStorage *ts = [[self layoutManager] textStorage]; if ([ts attribute:PFPathAttributeName atIndex:charIndex effectiveRange:NULL]) { // Only break if the previous character is not part of the path return [ts attribute:PFPathAttributeName atIndex:charIndex-1 effectiveRange:NULL] == nil; } } return YES; } I am setting the attribute PFPathAttributeName to the text storage to mark the path. This works somewhat, but now the problem is that after wrapping, the text looks like this: = Normally, you should never delete /Applications = This happens because -shouldBreakLineByWordBeforeCharacterAtIndex: never gets called for the '/' and the next time it gets called is for the 'd' in 'delete'. This modified wrapping behavior makes it seem like 'delete / Applications' is one word. I think it's better than the default behavior but still not ideal. So how can I make it wrap exactly the way I want? - Andy Kim 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: Controlling line-breaking in a text view
Hi Andy, I have never needed to work with this stuff, but with that caveat: Have you tried subclassing NSTextStorage and implementing -lineBreakBeforeIndex:withinRange:? -Ken On Sat, Aug 9, 2008 at 8:43 PM, Andy Kim [EMAIL PROTECTED] wrote: Hi, I'm having trouble figuring out how to make the text system not break words that begin with a '/', such as paths, when wrapping. Let's say that we're laying out the following line of text: = Normally, you should never delete /Applications = I want '/Applications' to stay intact when wrapping. By default, the text system wraps it the following way: = Normally, you should never delete / Applications = I'd like it to look like this: = Normally, you should never delete /Applications = After much searching, the best solution I've come up with so far is a subclass of NSATSTypesetter with the following method implementation in it: - (BOOL)shouldBreakLineByWordBeforeCharacterAtIndex:(NSUInteger)charIndex { NSString *string = [[[self layoutManager] textStorage] string]; if (charIndex = 1) { NSTextStorage *ts = [[self layoutManager] textStorage]; if ([ts attribute:PFPathAttributeName atIndex:charIndex effectiveRange:NULL]) { // Only break if the previous character is not part of the path return [ts attribute:PFPathAttributeName atIndex:charIndex-1 effectiveRange:NULL] == nil; } } return YES; } I am setting the attribute PFPathAttributeName to the text storage to mark the path. This works somewhat, but now the problem is that after wrapping, the text looks like this: = Normally, you should never delete /Applications = This happens because -shouldBreakLineByWordBeforeCharacterAtIndex: never gets called for the '/' and the next time it gets called is for the 'd' in 'delete'. This modified wrapping behavior makes it seem like 'delete /Applications' is one word. I think it's better than the default behavior but still not ideal. So how can I make it wrap exactly the way I want? - Andy Kim ___ 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/kenferry%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/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]