Performing the selector from a stored IMP
Hi folks I want to store a method pointer in a dictionary, recover it and call it from elsewhere in code. So, I have code like this to store the method pointer: { IMP anIMP = [anObject methodForSelector:@selector( myMethod: )]; [myDictionary setObject:anIMP forKey:myKey]; } … and then, elsewhere, I want to recover the IMP from the dictionary and invoke the selector on the self object that is held in the IMP. Or have I misunderstood what IMPs do? In C#, a delegate knows about the this, upon which the method will be called, within itself and can simply be called without having to go through any gymnastics to get the target object. Isn't this what IMPs do? TIA Joanna -- Joanna Carter Carter Consulting ___ 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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
On 2011 Feb 11, at 04:21, Joanna Carter wrote: IMP anIMP = [anObject methodForSelector:@selector( myMethod: )]; [myDictionary setObject:anIMP forKey:myKey]; The compiler should warn you on that second line that an IMP is not an object. This code won't work. Or have I misunderstood what IMPs do? You've misunderstood what an IMP *is*. In C#, a delegate knows about the this, upon which the method will be called, within itself and can simply be called without having to go through any gymnastics to get the target object. Isn't this what IMPs do? The equivalent of C++ 'this' in Objective-C is 'self'. But as you said, 'this' is an object, not a method. If you want to store a method, you could probably wrap that the pointer value of an IMP as an NSValue. Read NSValue. Or, for persistent storage, store the method name you get from NSStringFromSelector(), then retrieve it with NSSelectorFromString(). Use the latter technique sparingly because the compiler cannot warn you about undefined methods, etc. - think JavaScript. ___ 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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
Le 11 févr. 2011 à 13:21, Joanna Carter a écrit : Hi folks I want to store a method pointer in a dictionary, recover it and call it from elsewhere in code. So, I have code like this to store the method pointer: { IMP anIMP = [anObject methodForSelector:@selector( myMethod: )]; [myDictionary setObject:anIMP forKey:myKey]; } … and then, elsewhere, I want to recover the IMP from the dictionary and invoke the selector on the self object that is held in the IMP. Or have I misunderstood what IMPs do? IMP is just a function pointer. It does not record anything about the class that declare the corresponding method. In C#, a delegate knows about the this, upon which the method will be called, within itself and can simply be called without having to go through any gymnastics to get the target object. Isn't this what IMPs do? On Mac OS 10.6, you can use block to get something roughly equivalent to C# delegate. To define a delegate, you can do something like this: typedef void (^mydelegate)(id arg); To store your delegate in a dictionary, you can do something like this; [dict setObject:^(id arg) { [anObject myMethod:arg]; } forKey:@bar]; And to execute the delegate: mydelegate delegate = (mydelegate)[dict objectForKey:@bar]; delegate(@Hello World); -- Jean-Daniel ___ 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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
Hi Jerry You've misunderstood what an IMP *is*. Heheheh, I thought as much :-) If you want to store a method, you could probably wrap that the pointer value of an IMP as an NSValue. Read NSValue. Or, for persistent storage, store the method name you get from NSStringFromSelector(), then retrieve it with NSSelectorFromString(). Use the latter technique sparingly because the compiler cannot warn you about undefined methods, etc. - think JavaScript. (Fortunately, I don't know anything much about JavaScript, so hopefully that's less confusing) Anyway, from what you are saying, it would appear that NSSelectorFromString() would still need the target object in order to perform the selector, so that is just as useless :-) Whilst waiting for replies I have been busy rationalising things out and have come to the solution of declaring a MyDelegates protocol with the three delegate methods on it, implementing the protocol on the class, upon which I want to call the methods, and storing idMyDelegates references in the dictionary. This ensures that only a valid object, which implements the three delegates can be added to my static dictionary wrapper class and that that the wrapper class returns a valid (typesafe) instance with the three delegates available. I really am going to have to do some more reading to find out if and when I might want to use an IMP. Thank you Joanna -- Joanna Carter Carter Consulting ___ 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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
Le 11 févr. 2011 à 14:31, Joanna Carter a écrit : Hi Jerry You've misunderstood what an IMP *is*. Heheheh, I thought as much :-) If you want to store a method, you could probably wrap that the pointer value of an IMP as an NSValue. Read NSValue. Or, for persistent storage, store the method name you get from NSStringFromSelector(), then retrieve it with NSSelectorFromString(). Use the latter technique sparingly because the compiler cannot warn you about undefined methods, etc. - think JavaScript. (Fortunately, I don't know anything much about JavaScript, so hopefully that's less confusing) Anyway, from what you are saying, it would appear that NSSelectorFromString() would still need the target object in order to perform the selector, so that is just as useless :-) Whilst waiting for replies I have been busy rationalising things out and have come to the solution of declaring a MyDelegates protocol with the three delegate methods on it, implementing the protocol on the class, upon which I want to call the methods, and storing idMyDelegates references in the dictionary. This ensures that only a valid object, which implements the three delegates can be added to my static dictionary wrapper class and that that the wrapper class returns a valid (typesafe) instance with the three delegates available. I really am going to have to do some more reading to find out if and when I might want to use an IMP. The short answer is never. IMP is a low level detail of the runtime and is useful only in very few specific cases. Have a look at the following article for a better understanding of the runtime, and what IMP are for: http://www.mikeash.com/pyblog/friday-qa-2009-03-20-objective-c-messaging.html -- Jean-Daniel ___ 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 arch...@mail-archive.com
NSTreeNode mutableChildNodes documented as observable using key-value observing
The docs for NSTreeNode -mutableChildNodes states: The array that is returned is observable using key-value observing. This doesn't seem to make any sense nor does it seem to be true. What does seem to be true is that NSTreeNode - childNodes is observable using key-value observing. When -mutableChildNodes is mutated a KVO notification is raised for childNodes. An NSTreeNode instance can therefore observe its childNodes with: [self addObserver:self forKeyPath:@childNodes options:0 context:someContext]; Sorting the node children using NSTreeNode -sortWithSortDescriptors also generates a KVO notification on the childNodes path. I would seem then that childNodes can be observed to provide the same sort of binding behaviour as NSArrayController - arrangedObjects. Regards Jonathan Mitchell Developer Mugginsoft LLP http://www.mugginsoft.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 arch...@mail-archive.com
Re: Strange problem drawing a custom grid in NSTableView
I filed a bug report on this: rdar://8988596 Hopefully this will be fixed soon or a workaround provided. In the meantime, I will just disable the Automatically Hide Scrollers feature of NSScrollView. On Feb 10, 2011, at 7:07 PM, Eric Gorr wrote: Unfortunately, no. - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; } And, I just checked to see what would happen if I used the default column line drawing code instead of my custom code and I see the same problem. It appears that there is a general problem with drawing the vertical column lines in a NSTableView and it has nothing to do with my code. What I also noticed is that if I the scrollbars are always shown, the problem does not happen. So, I believe, the problem can be narrowed down to only when the automatically show/hide scrollbars is turned on. I suppose I will file a bug report, but I would like to know if there is a way to work around this problem. Thank you. On Feb 10, 2011, at 6:58 PM, Corbin Dunn wrote: override -drawRect: in NSTableView; just call [super drawRect:] and don't do anything else. Does that fix it? corbin On Feb 10, 2011, at 2:51 PM, Eric Gorr wrote: I've got a sample project demonstrating the problem: http://ericgorr.net/cocoadev/TableViewGridDrawing.zip I've included a screen recording showing the problem as well. Basically, I need to drawn some vertical column line in a column. Since, in the real case, these lines would be drawn for only some of the columns, I need to completely customize the -drawGridInClipRect: method. So,, the problem is that the rightmost line is not always drawn while I am resizing a column and it goes off the right edge and comes back. Whether the last line is drawn or not seems to be dependent upon how fast I am resizing a column. If I let the mouse button go and start again, the last line is drawn immediately. As best as I can determine there is some kind of caching of the grid lines going on because I can see my drawing code being called, but not see the complete result appear in the table. All of the other lines draw as expected. I thought it might be a clipping issue, but I do not believe that is the case. If anyone has any thoughts, I would be interested. Thank 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/mailist%40ericgorr.net This email sent to mail...@ericgorr.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 arch...@mail-archive.com
Re: Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)
Thank you both for your suggestions. I ended up going with Ken's idea regarding the synthetic property. It was added to a NSManagedObject derived class so I couldn't use it during the fetch request without actually adding an attribute but I did use it to sort the resulting array. The synthetic property computes an priority index when invoked. It performs very well. -Michael On Feb 8, 2011, at 5:19 PM, Ernesto Giannotta wrote: On 07-feb-2011, at 16:29, Ken Thomases wrote: On Feb 7, 2011, at 8:56 AM, Michael Crawford wrote: I'm trying to implement a feature where I sort a cross-section of music from multiple genres with up to two different keys, where the items with a genre matching the first key appear first in the collection and items with a genre matching the second key appear after the first group in the collection. All songs with a genre not matching the first or second keys can be in any order following the first two groups. So I took a look at NSSortDescriptor but it is not apparent to me how I would accomplish my goal with this class. If I sort with it based on the genre key, will basically sort them in alphabetical ascending or descending order, not what I want. Here are two possible approaches: 1) Implement a synthetic property which is more amenable to the sort ordering you want. Something which returns 0 for the first genre, 1 for the second, and 2 for all others, for example. 2) Implement a custom comparator method that compares the existing genre property in the manner you want: the first genre equal to itself but coming before all others; the second genre coming after the first, equal to itself, and coming before the remaining genres; all other genres coming after the first two but unordered with respect to each other. Either or both of these methods could be implemented in a category if that makes things easier. Or subclass the NSSortdescriptor and implement - (NSComparisonResult)compareObject:(id)object1 toObject:(id)object2 Cool Runnings, Erne. ___ 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 arch...@mail-archive.com
Re: Need help sorting with NSSortDescriptor and/or/NSPredicate (Core Data)
On Feb 11, 2011, at 9:19 AM, Michael Crawford wrote: Thank you both for your suggestions. You're welcome. I'm glad I could help. I ended up going with Ken's idea regarding the synthetic property. It was added to a NSManagedObject derived class so I couldn't use it during the fetch request without actually adding an attribute but I did use it to sort the resulting array. The synthetic property computes an priority index when invoked. It performs very well. By the way, I neglected to mention that you should also implement +keyPathsForValuesAffectingKey for your synthetic property returning the set of key paths which affect its value (e.g. the genre property). That's necessary for the synthetic property to be properly KVO-compliant. This should be standard operating procedure for all synthetic/derived properties. Cheers, Ken ___ 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 arch...@mail-archive.com
Carbon overlay window in place of a cocoa view
Hi, I've taken the Audio Unit (AU) code for carbon overlay windows over a cocoa view and modified it for my purposes as a proof of concept test. I needed to make some changes to improve the AU code in my case (the left edge of the cocoa view can move because it is on the right side of a split view). I have managed to remove the problems associated with the code except for one which is some tearing during redrawing in the carbon window when the cocoa window is being grown vertically and horizontally rapidly. Does anyone have some ideas as to how to remove the tearing. I've included the relevant bits of the proof of concept code below which is part of a class overriding a NSView. There is one odd thing about the code, and that is I load a carbon window with the defined views from a nib file, I then create the overlay window, insert the views into the created overlay window, then dispose of the nib window, and then add the overlay window into the cocoa window group. Thanks Kevin // - // fitCarbonWindowToCocoaView // - - (void)fitCarbonWindowToCocoaView { NSRect cocoaViewFrame = [self frame]; HIRect windowRect, cocoaWindowRect; // windowRect.size.width = cocoaViewFrame.size.width+0.5; // windowRect.size.height = cocoaViewFrame.size.height+0.5; windowRect.size.width = cocoaViewFrame.size.width; windowRect.size.height = cocoaViewFrame.size.height; NSPoint position = [[[self window] contentView] convertPoint:[self frame].origin fromView:self]; HIWindowGetBounds((WindowRef)[[self window] windowRef], kWindowContentRgn, kHICoordSpaceScreenPixel, cocoaWindowRect); windowRect.origin.x = cocoaWindowRect.origin.x + position.x / 2; windowRect.origin.y = (cocoaWindowRect.origin.y + cocoaWindowRect.size.height) - (position.y + cocoaViewFrame.size.height); HIWindowSetBounds(carbonWindow, kWindowContentRgn, kHICoordSpaceScreenPixel, windowRect); } // - // setFrame // - - (void)setFrame:(NSRect)theFrame { [super setFrame:theFrame]; [self fitCarbonWindowToCocoaView]; } // - // createCarbonOverlayWindow // - - (void)createCarbonOverlayWindow { HIViewRef carbonWindowRootControl; HIViewRef tmpWindowRootControl; HIViewRef viewToSwitchWindow; OSStatus result1, result2; WindowRef tempWindow = MyCreateWindow(); Rect bounds = {0,0,373,480}; if (!tempWindow) { NSLog(@createCarbonOverlayWindow: Could not load carbon window from nib.); return; } HideWindow(tempWindow); result1 = CreateNewWindow(kOverlayWindowClass, kWindowStandardHandlerAttribute | kWindowCompositingAttribute | kWindowOpaqueForEventsAttribute, bounds, carbonWindow); SetThemeWindowBackground(carbonWindow, kThemeTextColorWhite, YES); SetWindowActivationScope(carbonWindow, kWindowActivationScopeIndependent); if (result1) { NSLog(@createCarbonOverlayWindow: window creation failed result1= %d, result2=%d, result1, result2); return; } result1 = GetRootControl(carbonWindow, carbonWindowRootControl); result2 = GetRootControl(tempWindow, tmpWindowRootControl); if (result1 || result2) NSLog(@createCarbonOverlayWindow: Error getting root control result1=%d, result2=%d, result1, result2); viewToSwitchWindow = HIViewGetFirstSubview(tmpWindowRootControl); if (!viewToSwitchWindow) { NSLog(@Failure to get subview); return; } result1 = HIViewAddSubview(carbonWindowRootControl, viewToSwitchWindow); if (result1) { NSLog(@createCarbonOverlayWindow: failed to add the hiview); return; } // PrintToConsoleCarbonHIViewTree(carbonWindowRootControl, 0); [self fitCarbonWindowToCocoaView]; NSWindow *cocoaWindow = [self window]; WindowRef cocoaWindowRef = (WindowRef)[cocoaWindow windowRef]; NSWindow *mixedWindow = [[NSWindow alloc] initWithWindowRef:carbonWindow];
Re: Get ProcessSerialNumber of last front application
Would using carbon events be against the rules of the Mac App Store? I thought carbon was deprecated. I think it may just be the interface stuff in carbon, but not sure. On Feb 9, 2011, at 1:21 PM, Jean-Daniel Dupas wrote: Carbon events are events. As long as you don't receive one, your app is waiting consuming 0% of the CPU. Le 9 févr. 2011 à 20:05, Mr. Gecko a écrit : The only question I would have is if I were to track the applications all the time, how much time on the processor would it require, would it 1. require enough that will slow down the user noticeably, or 2. would it be like just 0.1% of cpu in a few milliseconds. I try to be considerate of the customer and not do things that'll cause slow downs and all. One reason for this is I'm stuck with my older mac and I don't like things that slow me down. My big guess is number 2. On Feb 9, 2011, at 12:55 PM, Matt Neuburg wrote: On Wed, 9 Feb 2011 09:23:45 -0600, Mr. Gecko grmrge...@gmail.com said: Hello, I am wondering how I can get the last front application ProcessSerialNumber so I can use SetFrontProcess to bring it back to front after they close the window to my application. You can track applications as they come to the front using Carbon Events. http://www.cocoabuilder.com/archive/cocoa/155984-detecting-frontmost-application.html 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/devlists%40shadowlab.org This email sent to devli...@shadowlab.org -- Jean-Daniel 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 arch...@mail-archive.com
Re: Get ProcessSerialNumber of last front application
Does your application compile on 64 bits ? Do you get a deprecation warning when using required functions ? When the answer is no for both questions, I personally consider that the function is not deprecated. If you have a specific question about Store validation, ask Apple directly. Nobody on this list can give you a definite answer. Le 11 févr. 2011 à 17:07, Mr. Gecko a écrit : Would using carbon events be against the rules of the Mac App Store? I thought carbon was deprecated. I think it may just be the interface stuff in carbon, but not sure. On Feb 9, 2011, at 1:21 PM, Jean-Daniel Dupas wrote: Carbon events are events. As long as you don't receive one, your app is waiting consuming 0% of the CPU. Le 9 févr. 2011 à 20:05, Mr. Gecko a écrit : The only question I would have is if I were to track the applications all the time, how much time on the processor would it require, would it 1. require enough that will slow down the user noticeably, or 2. would it be like just 0.1% of cpu in a few milliseconds. I try to be considerate of the customer and not do things that'll cause slow downs and all. One reason for this is I'm stuck with my older mac and I don't like things that slow me down. My big guess is number 2. On Feb 9, 2011, at 12:55 PM, Matt Neuburg wrote: On Wed, 9 Feb 2011 09:23:45 -0600, Mr. Gecko grmrge...@gmail.com said: Hello, I am wondering how I can get the last front application ProcessSerialNumber so I can use SetFrontProcess to bring it back to front after they close the window to my application. You can track applications as they come to the front using Carbon Events. http://www.cocoabuilder.com/archive/cocoa/155984-detecting-frontmost-application.html 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/devlists%40shadowlab.org This email sent to devli...@shadowlab.org -- Jean-Daniel -- Jean-Daniel ___ 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 arch...@mail-archive.com
Re: Get ProcessSerialNumber of last front application
Thanks, I'm working out the code now and if it will compile on 64bit, then I'll use it. On Feb 11, 2011, at 10:15 AM, Jean-Daniel Dupas wrote: Does your application compile on 64 bits ? Do you get a deprecation warning when using required functions ? When the answer is no for both questions, I personally consider that the function is not deprecated. If you have a specific question about Store validation, ask Apple directly. Nobody on this list can give you a definite answer. 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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
Date: Fri, 11 Feb 2011 12:21:29 + From: Joanna Carter cocoa...@carterconsulting.org.uk Subject: Performing the selector from a stored IMP I want to store a method pointer in a dictionary, recover it and call it from elsewhere in code. Consider NSInvocation... m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ pantes anthropoi tou eidenai oregontai phusei Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide, 2nd edition http://www.tidbits.com/matt/default.html#applescriptthings Take Control of Exploring Customizing Snow Leopard http://tinyurl.com/kufyy8 RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html TidBITS, Mac news and reviews since 1990, http://www.tidbits.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 arch...@mail-archive.com
Re: [ANN] Cong 0.7
Really excellent work on this! Nice job catching the fact that I was using an embedded framework and kept the headers in there...though I'm not sure how to automate the removal of them during the build (hmm). It would be great if this was part of Xcode in some way (obviously a tough request). Oh, and Strange name for a framework made me laugh. Sincerely, Carter Allen On Feb 10, 2011, at 5:21 PM, Stephane Sudre wrote: After checking your code with the Build and Analysis features of Xcode, your leaks with Instruments, you may want to check the resources of your Mac OS X application with Cong. Cong is a free application that checks the contents of application bundles and looks for glitches such as: - Deprecated keys in Info.plist files - Missing files referenced by Info.plist values - .strings files with no values defined in them - Duplicate entries in .strings files - Common typos with punctuation marks - etc. Cong is available here: http://s.sudre.free.fr/Software/Cong/about.html Hope it can help. -- Stephane ___ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (xcode-us...@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/xcode-users/lists%40cartera.me This email sent to li...@cartera.me ___ 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 arch...@mail-archive.com
Re: [ANN] Cong 0.7
On Feb 11, 2011, at 9:57 AM, Carter Allen li...@cartera.me wrote: Really excellent work on this! Nice job catching the fact that I was using an embedded framework and kept the headers in there...though I'm not sure how to automate the removal of them during the build (hmm). It would be great if this was part of Xcode in some way (obviously a tough request). Oh, and Strange name for a framework made me laugh. Mark their role as private in the framework project and use a post-build script phase on the app target to remove the PrivateHeaders directories from all embedded frameworks. --Kyle Sluder___ 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 arch...@mail-archive.com
NSUnicodeStringEncoding
Looking at the NSString class there is the method initWithBytes:length:encoding: I have a unicode string (in C++ object) that I can extract in a number of different byte stream formats (UTF-8, UTF-16 (w or w/o BOM)) that I need to encode into an NSString. Does the NSUnicodeStringEncoding refer to UTF-8 encoding? Thanks, Todd ___ 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 arch...@mail-archive.com
Re: NSUnicodeStringEncoding
On Fri, Feb 11, 2011 at 10:57 AM, Todd Heberlein todd_heberl...@mac.com wrote: Looking at the NSString class there is the method initWithBytes:length:encoding: I have a unicode string (in C++ object) that I can extract in a number of different byte stream formats (UTF-8, UTF-16 (w or w/o BOM)) that I need to encode into an NSString. Does the NSUnicodeStringEncoding refer to UTF-8 encoding? No. See the NSStringEncoding documentation: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/uid/2154-BAJJAICE NSUnicodeStringEncoding is an alias for NSUTF16StringEncoding. You're best off getting UTF16 from your C++ string and explicitly using the NSUTF16StringEncoding constant when creating your NSString. Since UTF16 is the canonical representation of strings, this will result in the fewest conversions, and using the explicit UTF16 constant rather than the equivalent NSUnicodeStringEncoding will make your code clearer. --Kyle Sluder ___ 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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
Hi Matt Consider NSInvocation... m. Hmmm, nice! My only objection to using it in the circumstances I have is that it is a lot more code to setup than the idea of a protocol with three methods, implemented by the target class. However, I am indebted to you for pointing out this class and shall remember it for future use. IMO, this is truly the next best thing to a delegate (as it is known in C#). Joanna -- Joanna Carter Carter Consulting ___ 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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
Hello, Being curious about the performance implications of using NSInvocation vs Objective-C message send vs IMP-cached message send, I was surprised to see how much slower NSInvocation seems to be compared to the other two mechanisms (the following data was last collected on Leopard, so these results could have changed in SnowLeopard): NameIterations Total time (sec) Time per (ns) IMP-cached message send 10 0.7 0.7 Objective-C message send10 4.9 4.9 NSInvocation message send 10000.8 77.3 The above metrics can be found here: http://www.mikeash.com/pyblog/performance-comparisons-of-common-operations-leopard-edition.html Cheers, -- Tito On Feb 11, 2011, at 12:20 PM, Joanna Carter wrote: Hi Matt Consider NSInvocation... m. Hmmm, nice! My only objection to using it in the circumstances I have is that it is a lot more code to setup than the idea of a protocol with three methods, implemented by the target class. However, I am indebted to you for pointing out this class and shall remember it for future use. IMO, this is truly the next best thing to a delegate (as it is known in C#). Joanna -- Joanna Carter Carter Consulting ___ 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/tciuro%40mac.com This email sent to tci...@mac.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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
On Feb 11, 2011, at 12:20 PM, Joanna Carter wrote: Consider NSInvocation... m. Hmmm, nice! My only objection to using it in the circumstances I have is that it is a lot more code to setup But consider NSUndoManager. What its +prepareWithInvocationTarget:+ does is almost exactly what you describe: you give it a target and send it a method call, a method call that NSUndoManager itself cannot respond to. Instead of complaining, it freeze-dries that method call and its parameters and the target into an NSInvocation and puts it on the Undo stack. (This is the only place where it differs from what you said; you said a dictionary.) When you later say undo to the NSUndoManager, it pops that NSInvocation off the stack, un-freeze-dries it, and calls it. So NSUndoManager has a completely general way of freeze-drying *any* method call into an NSInvocation, on the spot! It isn't doing this by magic; it's using Objective-C's wonderful runtime. And so can you. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ pantes anthropoi tou eidenai oregontai phusei Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide, 2nd edition http://www.tidbits.com/matt/default.html#applescriptthings Take Control of Exploring Customizing Snow Leopard http://tinyurl.com/kufyy8 RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html TidBITS, Mac news and reviews since 1990, http://www.tidbits.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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
Hi Matt But consider NSUndoManager. What its +prepareWithInvocationTarget:+ does is almost exactly what you describe: you give it a target and send it a method call, a method call that NSUndoManager itself cannot respond to. Instead of complaining, it freeze-dries that method call and its parameters and the target into an NSInvocation and puts it on the Undo stack. (This is the only place where it differs from what you said; you said a dictionary.) When you later say undo to the NSUndoManager, it pops that NSInvocation off the stack, un-freeze-dries it, and calls it. So NSUndoManager has a completely general way of freeze-drying *any* method call into an NSInvocation, on the spot! It isn't doing this by magic; it's using Objective-C's wonderful runtime. And so can you. m. I would totally agree that it is a phenomenally powerful concept, giving just the kind of functionality I was originally looking for, as a replacement for method pointers. I will be using it as soon as I find a need that warrants it. But, in my current code, I realise now that it was a lot easier to simply take the protocol/method approach. In addition to pointing me to NSInvocation, you have lifted the mist from my eyes as to how NSUndoManager can work. Once again, many thanks. Joanna -- Joanna Carter Carter Consulting ___ 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 arch...@mail-archive.com
Re: [ANN] Cong 0.7
I have two apps in the store now. I run Cong and drag the release version of either one from the Build folder onto Cong. It gives me one report -- ./Contents folder not found. Earlier versions of these have been accepted and put on the store. What is it telling me? Am I using it wrong? On Feb 11, 2011, at 10:33 AM, Kyle Sluder wrote: On Feb 11, 2011, at 9:57 AM, Carter Allen li...@cartera.me wrote: Really excellent work on this! Nice job catching the fact that I was using an embedded framework and kept the headers in there...though I'm not sure how to automate the removal of them during the build (hmm). It would be great if this was part of Xcode in some way (obviously a tough request). Oh, and Strange name for a framework made me laugh. Mark their role as private in the framework project and use a post-build script phase on the app target to remove the PrivateHeaders directories from all embedded frameworks. --Kyle Sluder___ 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/rowlandd%40sbcglobal.net This email sent to rowla...@sbcglobal.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 arch...@mail-archive.com
Re: Performing the selector from a stored IMP
On Feb 11, 2011, at 1:16 PM, Joanna Carter wrote: I would totally agree that it is a phenomenally powerful concept, giving just the kind of functionality I was originally looking for, as a replacement for method pointers. I will be using it as soon as I find a need that warrants it. But, in my current code, I realise now that it was a lot easier to simply take the protocol/method approach. While fast, IMP caching can also be dangerous. If anything happens such that the IMP changes while you have it cached, you'll end up calling the wrong thing. In particular, if you cache an IMP for something that can be observed with KVO, it can lead to problems. Bundle loading can also be an issue; categories can replace IMPs. Obviously, method swizzling -- in general -- will cause issues. (Just an FYI -- none of these are *huge* issues, just something to be aware of) b.bum ___ 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 arch...@mail-archive.com
specifying new document types that an app opens
I'm working on a document-based app for the Mac App Store. The data file I'm reading/writing is actual a Sqlite database file. I've been able to get it to work with the following in my info.plist file (although for this email I've used appname in place of the actual appname and file extension I'm using. keyCFBundleDocumentTypes/key array dict keyCFBundleTypeExtensions/key array stringappname/string /array keyCFBundleTypeIconFile/key stringAppName.icns/string keyCFBundleTypeName/key stringAppName Document/string keyCFBundleTypeRole/key stringEditor/string keyNSDocumentClass/key stringMyDocument/string /dict /array keyUTExportedTypeDeclarations/key array dict keyUTTypeDescription/key stringAppName document/string keyUTTypeIdentifier/key stringcom.dave256apps.appname/string keyUTTypeTagSpecification/key dict keypublic.filename-extension/key stringappname/string /dict /dict /array It appears CFBundleTypeExtensions is deprecated and I should be using LSItemContentTypes, but I can't get it to work with that. What exactly should the plist file look like to work with that? Also, will making these changes prevent me from opening documents I've already created with it set up as above? If so, is there a way around it. Thanks in advance, Dave ___ 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 arch...@mail-archive.com
NSTableView auto sorting does not work
I have experienced that an NSTableview which is bound to an array controller will sometimes automatically sort when their column headers are clicked and sometimes not. As an example, I currently have two windows, each with a tableview bound to an array controller. One tableview sorts, the other does not. For both tableviews each column is bound to the arranged objects of its respective array controller and has Creates Sort Descriptor selected in IB.Yes, I could use delegates and implement my own sort descriptors but getting free sorting is really nice and it works for some of my tableviews, so I'd like to find out what breaks this functionality. ___ 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 arch...@mail-archive.com
Re: NSTableView auto sorting does not work
On Fri, Feb 11, 2011 at 5:14 PM, Chris Tracewell ch...@thinkcl.com wrote: I have experienced that an NSTableview which is bound to an array controller will sometimes automatically sort when their column headers are clicked and sometimes not. As an example, I currently have two windows, each with a tableview bound to an array controller. One tableview sorts, the other does not. For both tableviews each column is bound to the arranged objects of its respective array controller and has Creates Sort Descriptor selected in IB.Yes, I could use delegates and implement my own sort descriptors but getting free sorting is really nice and it works for some of my tableviews, so I'd like to find out what breaks this functionality. Did you actually bind the table view's sortDescriptors binding to the array controller's sortDescriptors property? In the simplest case (all columns bound to different keys on the same NSArrayController), NSTableView will automagically bind its selectedIndexes and its sortDescriptors bindings to the relevant properties on the array controller. But if your columns aren't all bound to the same array controller, the table view can't logically do this, so you are responsible for binding these yourself. --Kyle Sluder ___ 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 arch...@mail-archive.com
Looking for suggestions/help on a multi-file data model
I'm working on an application that has multiple files as part of its data model, and I'm not sure on the approach I should take. An example of what I mean: Imagine a purchasing application. First, you have to open a catalog - a file that lists the items that are available. There might be multiple files, representing multiple stores or sets of items, but you have to pick just one. Then, you have your order - you select items from the opened catalog, and have a new document that contains not only the items you are going to order, but also other information (address, name, etc). The catalogs are separate files, and there would be either a separate app or a part of this app to edit a catalog: to add, remove, change items in it. But orders are also separate files, that can be saved, edited, printed, etc. I've used Core Data and the Document architecture for more simple data models, but I'm not sure if I can shoehorn this into them. I've looked at several tutorials, guides, and even read some books - but they all seem to be the One Document = One File approach. And what I want to do really doesn't fit that. Note: The above is just a conceptual example - I'm not really writing a purchasing/catalog system. It was just what I thought of to describe my problem :) The actual product I'm working on is a bit more niche oriented, but the use case of the data involved follows the same concept: the prime document (order) is built/constructed using data from a defining document/template (catalog). Can anyone point me in a direction to do some more research and/or offer some insight that might help me decide if I can use Core Data and/or Document Architecture, of if I have to go old school and roll my own? Heck, perhaps I can use CD/DA for the primary document, and have the template/definition document be something else. I hope this wasn't too obscure - I'm not looking for a concrete solution. Instead, hoping for a little guidance/ideas on what I should try and/or look into. Thanks for any insight you might have... -- Andy Akins ___ 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 arch...@mail-archive.com