From ahoesch at smartsoft.de Fri May 2 07:54:29 2008 From: ahoesch at smartsoft.de (=?ISO-8859-1?Q?Andreas_H=F6schler?=) Date: Fri May 2 07:54:39 2008 Subject: First steps in xCode In-Reply-To: <1CAF0455-205C-42AC-AFAC-1AC0A04D4846@joar.com> Message-ID: Hi all, >> How can I convince xCode to create a framework with a Headers >> directory? I have >> >> Targets >> SRTest >> Copy Headers >> Person.h >> >> in Groups & Files and assumed this would tell xCode to copy to create >> the Headers dir. But this does not seem to be the case. A framework >> without a Headers is absolutely useless. I googled for hours but >> found nothing. I am currently running xCode 3.0 but have also already >> tried newer builds. Nope! > > > Select the "Copy Headers" build phase and look in the Detail View > where you will find the header files listed. Look for the "Role" > column, and make sure to mark all headers that you want to have copied > to the Headers folder as "Public". In the meanwhile I figured out how to export the headers of a framework. The http://rentzsch.com/share/embeddingFrameworks.mov explains this in greate detail, also how to embed a framework into an application. However, I want to install the Frameworks in /Library/Frameworks so that multiple applications can access them. I opened "Get Info " on the Target and made sure "Installation directory" is set to "/Library/Frameworks". Unfortunately this setting seems to be ignored. The Framework is installed in /Build/Release instead. Any idea? Thanks, Andreas From cmhofman at gmail.com Fri May 2 08:24:45 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Fri May 2 08:24:55 2008 Subject: First steps in xCode In-Reply-To: References: Message-ID: On 2 May 2008, at 4:54 PM, Andreas H?schler wrote: > Hi all, > >>> How can I convince xCode to create a framework with a Headers >>> directory? I have >>> >>> Targets >>> SRTest >>> Copy Headers >>> Person.h >>> >>> in Groups & Files and assumed this would tell xCode to copy to >>> create the Headers dir. But this does not seem to be the case. A >>> framework without a Headers is absolutely useless. I googled for >>> hours but found nothing. I am currently running xCode 3.0 but have >>> also already tried newer builds. Nope! >> >> >> Select the "Copy Headers" build phase and look in the Detail View >> where you will find the header files listed. Look for the "Role" >> column, and make sure to mark all headers that you want to have >> copied to the Headers folder as "Public". > > In the meanwhile I figured out how to export the headers of a > framework. The http://rentzsch.com/share/embeddingFrameworks.mov > explains this in greate detail, also how to embed a framework into > an application. However, I want to install the Frameworks in / > Library/Frameworks so that multiple applications can access them. I > opened "Get Info " on the Target and made sure "Installation > directory" is set to "/Library/Frameworks". Unfortunately this > setting seems to be ignored. The Framework is installed in /Build/ > Release instead. > > Any idea? > > Thanks, > > Andreas Copied from the Xcode documentation: Deployment Location (DEPLOYMENT_LOCATION) Specifies whether the build system places the product in the location specified by the DSTROOT and INSTALL_PATH build settings. Christiaan From ahoesch at smartsoft.de Fri May 2 09:15:46 2008 From: ahoesch at smartsoft.de (=?ISO-8859-1?Q?Andreas_H=F6schler?=) Date: Fri May 2 09:15:51 2008 Subject: First steps in xCode In-Reply-To: Message-ID: <0576739B-1863-11DD-A399-000393CA0072@smartsoft.de> Hi Christiaan, > > In the meanwhile I figured out how to export the headers of a > framework. The http://rentzsch.com/share/embeddingFrameworks.mov > explains this in greate detail, also how to embed a framework into an > application. However, I want to install the Frameworks in > /Library/Frameworks so that multiple applications can access them. I > opened "Get Info " on the Target and made sure "Installation > directory" is set to "/Library/Frameworks". Unfortunately this setting > seems to be ignored. The Framework is installed in /Build/Release > instead. > > Any idea? > > Thanks, > > ?Andreas > > > Copied from the Xcode documentation: > > Deployment Location (DEPLOYMENT_LOCATION) > Specifies whether the build system places the product in the location > specified by the?DSTROOT?and?INSTALL_PATH?build settings. I realized this Deployment Location check in "Get Info". I checked it. I now have Deployment Location is checked Installation Directory /Library/Frameworks I still get nothing in /Library/Frameworks. Instead I get lrwxrwxrwx 1 ahoesch wheel 55 May 2 18:10 SRMapKit.framework -> /tmp/SRMapKit.dst/Library/Frameworks/SRMapKit.framework in /Build/Release. I am clueless!? Thanks, Andreas From cmhofman at gmail.com Fri May 2 09:21:24 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Fri May 2 09:21:36 2008 Subject: First steps in xCode In-Reply-To: <0576739B-1863-11DD-A399-000393CA0072@smartsoft.de> References: <0576739B-1863-11DD-A399-000393CA0072@smartsoft.de> Message-ID: On 2 May 2008, at 6:15 PM, Andreas H?schler wrote: > Hi Christiaan, > >> >> In the meanwhile I figured out how to export the headers of a >> framework. The http://rentzsch.com/share/embeddingFrameworks.mov >> explains this in greate detail, also how to embed a framework into >> an application. However, I want to install the Frameworks in / >> Library/Frameworks so that multiple applications can access them. I >> opened "Get Info " on the Target and made sure "Installation >> directory" is set to "/Library/Frameworks". Unfortunately this >> setting seems to be ignored. The Framework is installed in /Build/ >> Release instead. >> >> Any idea? >> >> Thanks, >> >> Andreas >> >> >> Copied from the Xcode documentation: >> >> Deployment Location (DEPLOYMENT_LOCATION) >> Specifies whether the build system places the product in the >> location specified by the DSTROOT and INSTALL_PATH build settings. > > I realized this Deployment Location check in "Get Info". I checked > it. I now have > > Deployment Location is checked > Installation Directory /Library/Frameworks > > I still get nothing in /Library/Frameworks. Instead I get > > lrwxrwxrwx 1 ahoesch wheel 55 May 2 18:10 SRMapKit.framework - > > /tmp/SRMapKit.dst/Library/Frameworks/SRMapKit.framework > > in /Build/Release. I am clueless!? > > Thanks, > > Andreas So that's probably a link to the installation build product? I guess that should tell you what to do. Christiaan From ahoesch at smartsoft.de Fri May 2 09:41:33 2008 From: ahoesch at smartsoft.de (=?ISO-8859-1?Q?Andreas_H=F6schler?=) Date: Fri May 2 09:41:38 2008 Subject: First steps in xCode In-Reply-To: Message-ID: <9FC0543E-1866-11DD-A399-000393CA0072@smartsoft.de> Hi Christiaan, >> I realized this Deployment Location check in "Get Info". I checked >> it. I now have >> >> Deployment Location is checked >> Installation Directory /Library/Frameworks >> >> I still get nothing in /Library/Frameworks. Instead I get >> >> lrwxrwxrwx 1 ahoesch wheel 55 May 2 18:10 SRMapKit.framework >> -> /tmp/SRMapKit.dst/Library/Frameworks/SRMapKit.framework >> >> in /Build/Release. I am clueless!? >> >> Thanks, >> >> Andreas > > So that's probably a link to the installation build product? I guess > that should tell you what to do. Please exclude my ignorance, but this tells me nothing. When I told ProjectBuilder.app to install software in /Library/Frameworks, it installed it there. XCode has numerous places where one can set an Installation Directory (in Get Info of the Target, in Get Info of the project itself,...) which is confusing and even if I set all these values to /Library/Frameworks it still installs stuff somewhere else!? This is really far from intuitive and user/newbie friendly. Hints are still very much appreciated since it's still not working for me! Thanks a lot, Andreas From cmhofman at gmail.com Fri May 2 09:49:17 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Fri May 2 09:49:26 2008 Subject: First steps in xCode In-Reply-To: <9FC0543E-1866-11DD-A399-000393CA0072@smartsoft.de> References: <9FC0543E-1866-11DD-A399-000393CA0072@smartsoft.de> Message-ID: On 2 May 2008, at 6:41 PM, Andreas H?schler wrote: > Hi Christiaan, > >>> I realized this Deployment Location check in "Get Info". I checked >>> it. I now have >>> >>> Deployment Location is checked >>> Installation Directory /Library/Frameworks >>> >>> I still get nothing in /Library/Frameworks. Instead I get >>> >>> lrwxrwxrwx 1 ahoesch wheel 55 May 2 18:10 >>> SRMapKit.framework -> /tmp/SRMapKit.dst/Library/Frameworks/ >>> SRMapKit.framework >>> >>> in /Build/Release. I am clueless!? >>> >>> Thanks, >>> >>> Andreas >> >> So that's probably a link to the installation build product? I >> guess that should tell you what to do. > > Please exclude my ignorance, but this tells me nothing. If you look in the build settings you see that /tmp/SRMapKit.dst is the value of the "installation build product"=DSTROOT. If you read the xcode docs you can see that the installation directory is relative to DSTROOT. I'm trying to give hints so you can solve problems yourself. > When I told ProjectBuilder.app to install software in /Library/ > Frameworks, it installed it there. XCode has numerous places where > one can set an Installation Directory (in Get Info of the Target, in > Get Info of the project itself,...) which is confusing and even if I > set all these values to /Library/Frameworks it still installs stuff > somewhere else!? This is really far from intuitive and user/newbie > friendly. > Only one setting for each key is used. The different places where you can set it are explained in the docs. I advice you to read those before asking a question here. > Hints are still very much appreciated since it's still not working > for me! > First follow the hints the actual results give you and read the docs. Then you can ask questions to others. Christiaan > Thanks a lot, > > Andreas From ahoesch at smartsoft.de Fri May 2 10:00:57 2008 From: ahoesch at smartsoft.de (=?ISO-8859-1?Q?Andreas_H=F6schler?=) Date: Fri May 2 10:01:05 2008 Subject: First steps in xCode In-Reply-To: Message-ID: <556505B6-1869-11DD-A399-000393CA0072@smartsoft.de> Hello all, >>> Deployment Location (DEPLOYMENT_LOCATION) >>> Specifies whether the build system places the product in the >>> location specified by the DSTROOT and INSTALL_PATH build settings. >> >> I realized this Deployment Location check in "Get Info". I checked >> it. I now have >> >> Deployment Location is checked >> Installation Directory /Library/Frameworks >> >> I still get nothing in /Library/Frameworks. Instead I get Thanks a lot for all hints. I have it working now! For all late ProjectBuilder -> XCode migrators with the same problem, three non-default settings are required to get frameworks installed in /Library/Frameworks: Deployment Location checked Installation Directory /Library/Frameworks Installation Build Products Location / Thanks a lot, Andreas From andreas at harmless.de Fri May 2 11:53:22 2008 From: andreas at harmless.de (Andreas Mayer) Date: Fri May 2 11:53:21 2008 Subject: [ANN] New version of AMRollOverButton with IB3 plugin Message-ID: Rollover buttons highlight when you move the mouse pointer over them. The appearance is widely configurable. Now comes with an Interface Builder 3.x plugin. http://www.harmless.de/cocoa-code.php#rollover This source code is available under the BSD License. Andreas From mattejames at gmail.com Sat May 3 18:14:45 2008 From: mattejames at gmail.com (Matt James) Date: Sat May 3 18:14:50 2008 Subject: CALayer Lookup by Name Message-ID: <27cd4a440805031814y3e30bf77h775c08f76b7a331c@mail.gmail.com> Hello everyone, I've been doing a bit of Core Animation recently and have been starting to notice the trickery involved with accessing a layer. It seems as though the only way to get at one is to save it to a local variable on an object for later retrieval. Ideally, I'd like to snag it by name on-command rather than dealing with setting up a variable (or property) every time, but there doesn't seem to be a way to do that which seems strange to me because with CAConstraintLayoutManager, you _can_ reference a layer by name. Am I missing something obvious or does CALayer not have a method for looking up and returning a sublayer by name? If not, sounds like a perfect place to put a category! -Matt James From sstevenson at mac.com Sat May 3 22:18:21 2008 From: sstevenson at mac.com (Scott Stevenson) Date: Sat May 3 22:19:10 2008 Subject: CALayer Lookup by Name In-Reply-To: <27cd4a440805031814y3e30bf77h775c08f76b7a331c@mail.gmail.com> References: <27cd4a440805031814y3e30bf77h775c08f76b7a331c@mail.gmail.com> Message-ID: On May 3, 2008, at 6:14 PM, Matt James wrote: > I've been doing a bit of Core Animation recently and have been > starting to > notice the trickery involved with accessing a layer. It seems as > though the > only way to get at one is to save it to a local variable on an > object for > later retrieval. Pretty much, yes. > Am I missing something obvious or does CALayer not have a method for > looking up > and returning a sublayer by name? If not, sounds like a perfect > place to > put a category! You're not missing anything obvious. The lack of a "layerForName:" might have something to do with the fact that layer names aren't necessarily unique. The easiest way to do what you want is to just write a category called -firstLayerNamed: which loops through sublayers until it finds one. CALayers are generic KVC containers so you could also do this: CALayer* parent = [CALayer layer]; CALayer* child = [CALayer layer]; CALayer* grandchild = [CALayer layer]; [parent addSublayer:child]; [parent setValue:child forKey:@"child"]; [child addSublayer:grandchild]; [child setValue:grandchild forKey:@"grandchild"]; NSLog(@"layer: %@", [parent valueForKeyPath:@"child.grandchild"]); - Scott From cmhofman at gmail.com Sun May 4 15:17:12 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Sun May 4 15:17:19 2008 Subject: C-function returning? Message-ID: Hi list, I'm struggling with a very weird problem. I have a method that sort of looks as follows: - (id)doSomething:(id)argument { NSLog(@"before"); id value = callCFunction(argument); NSLog(@"after"); // rest of the method return value; } I don't think it should really matter what the c-function is or the precise method name or the rest of the implementation (right?) Anyway, when this method is called, I see the log for "before", but not "after". So apparently the C-function callCFunction implicitly returns! AFAIK this should not be possible. Or am I wrong? I am totally lost. Anyone have an idea? Thanks, Christiaan From sstevenson at mac.com Sun May 4 15:38:26 2008 From: sstevenson at mac.com (Scott Stevenson) Date: Sun May 4 15:39:14 2008 Subject: C-function returning? In-Reply-To: References: Message-ID: On May 4, 2008, at 3:17 PM, Christiaan Hofman wrote: > I don't think it should really matter what the c-function is or the > precise method name or the rest of the implementation (right?) > Anyway, when this method is called, I see the log for "before", but > not "after". So apparently the C-function callCFunction implicitly > returns! There's nothing wrong with the code you sent to the list, so it's hard to say exactly what's happening without seeing the complete context. - Scott From mah at jump-ing.de Sun May 4 15:49:53 2008 From: mah at jump-ing.de (Markus Hitter) Date: Sun May 4 15:50:00 2008 Subject: C-function returning? In-Reply-To: References: Message-ID: <5C4D6440-1608-4AD4-8834-43BEAF33A660@jump-ing.de> Am 05.05.2008 um 00:17 schrieb Christiaan Hofman: > id value = callCFunction(argument); Are you sure this C function returns a valid Obj-C object or class? A plain variable of type int, double, or alike, won't cut it. > So apparently the C-function callCFunction implicitly returns! Would be interesting what this function does. Trigger an exception? Fiddle with stack pointers? Markus - - - - - - - - - - - - - - - - - - - Dipl. Ing. Markus Hitter http://www.jump-ing.de/ From mattejames at gmail.com Mon May 5 05:07:34 2008 From: mattejames at gmail.com (Matt James) Date: Mon May 5 05:07:40 2008 Subject: CALayer autoResizingMask Message-ID: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> Hello everyone, I'm having some trouble with autoResizingMask and kCATransactionDisableActions. My layers are laid out thus. - Layer-backed NSView Subclass - CAScrollLayer - Several CALayer subclass instances - CALayer (A) - CATextLayer (B) - CATextLayer (C) To give some important background, I'm using a custom layout manager for CAScrollLayer which adjusts the height, width and position of the items it directly contains. Meanwhile, Layer A has its autoResizingMask set to "kCALayerHeightSizable | kCALayerWidthSizable". So, when I resize my window, the resizing trickles down the hierarchy just as it should. The CAScrollLayer resizes, each CALayer subclass instance resizes using the custom layout manager, and layers A, B, and C all resize. The problem is that A implicitly animates the resizing. So, as I resize the window the instances of Layer A are all rubber-bandy rather than instantly resizing. So, under the advice of a fellow Cocoa programmer, I attempted to use a CATransaction with kCATransactionDisableActions turned on to make the resizing more instantaneous. Unfortunately, this was to no avail. I've tried applying it in all the places I could think of -- around the height/width adjustments in my custom layout manager, within the CALayer subclass instances' resizeSublayersWithOldSize:, within Layer A's resizeWithOldSuperlayerSize:, and on and on. Nothing seems to work. Does anyone have recommendations for how to get the effect I'm looking for? Thanks for any help! -Matt From john_clayton at mac.com Mon May 5 07:46:46 2008 From: john_clayton at mac.com (John Clayton) Date: Mon May 5 07:46:59 2008 Subject: CALayer autoResizingMask In-Reply-To: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> References: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> Message-ID: Are you using CATiledLayer instances by any chance? The other thing you can try is the following, instead of disable actions - try this: // this is a category method on the CALayer - (void) disableAnimationsForBoundsAndPosition { // This in theory disabled animations for these properties NSDictionary * disabledAnimation = [NSDictionary dictionaryWithObjectsAndKeys: [NSNull null], @"bounds", [NSNull null], @"position", nil]; self.actions = disabledAnimation; } -- John Clayton http://www.coderage-software.com/ On May 5, 2008, at 2:07 PM, Matt James wrote: > Hello everyone, > I'm having some trouble with autoResizingMask > and kCATransactionDisableActions. My layers are laid out thus. > > - Layer-backed NSView Subclass > - CAScrollLayer > - Several CALayer subclass instances > - CALayer (A) > - CATextLayer (B) > - CATextLayer (C) > > To give some important background, I'm using a custom layout manager > for > CAScrollLayer which adjusts the height, width and position of the > items it > directly contains. Meanwhile, Layer A has its autoResizingMask set to > "kCALayerHeightSizable | kCALayerWidthSizable". So, when I resize my > window, the resizing trickles down the hierarchy just as it should. > The > CAScrollLayer resizes, each CALayer subclass instance resizes using > the > custom layout manager, and layers A, B, and C all resize. The > problem is > that A implicitly animates the resizing. So, as I resize the window > the > instances of Layer A are all rubber-bandy rather than instantly > resizing. > So, under the advice of a fellow Cocoa programmer, I attempted to > use a > CATransaction with kCATransactionDisableActions turned on to make the > resizing more instantaneous. Unfortunately, this was to no avail. > I've > tried applying it in all the places I could think of -- around the > height/width adjustments in my custom layout manager, within the > CALayer > subclass instances' resizeSublayersWithOldSize:, within Layer > A's resizeWithOldSuperlayerSize:, and on and on. Nothing seems to > work. > > Does anyone have recommendations for how to get the effect I'm > looking for? > Thanks for any help! > > -Matt > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev From mattejames at gmail.com Mon May 5 15:13:23 2008 From: mattejames at gmail.com (Matt James) Date: Mon May 5 15:13:29 2008 Subject: CALayer autoResizingMask In-Reply-To: References: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> Message-ID: <27cd4a440805051513u11a90a7arbce73de2f1d9fe3b@mail.gmail.com> Hm, I hadn't heard of CATiledLayer (still fairly new to Core Animation). Looks interesting, though. Do you think that shifting to a CATiledLayer will work better? If so, what advantages does a TiledLayer have over a regular Layer that would aid in this issue? As for the method you suggest, I'll definitely give that a shot. If it works, can I assume there is a bug preventing my use of the disableActions constant from working in this case? Thanks for your help! -Matt On Mon, May 5, 2008 at 10:46 AM, John Clayton wrote: > Are you using CATiledLayer instances by any chance? > The other thing you can try is the following, instead of disable actions - > try this: > > // this is a category method on the CALayer > - (void) disableAnimationsForBoundsAndPosition { > // This in theory disabled animations for these properties > NSDictionary * disabledAnimation = > [NSDictionary dictionaryWithObjectsAndKeys: [NSNull null], @"bounds", [ > NSNull null], @"position", nil]; > > > self.actions = disabledAnimation; > } > > > -- > John Clayton > http://www.coderage-software.com/ > > > > On May 5, 2008, at 2:07 PM, Matt James wrote: > > Hello everyone, > I'm having some trouble with autoResizingMask > and kCATransactionDisableActions. My layers are laid out thus. > > - Layer-backed NSView Subclass > - CAScrollLayer > - Several CALayer subclass instances > - CALayer (A) > - CATextLayer (B) > - CATextLayer (C) > > To give some important background, I'm using a custom layout manager for > CAScrollLayer which adjusts the height, width and position of the items it > directly contains. Meanwhile, Layer A has its autoResizingMask set to > "kCALayerHeightSizable | kCALayerWidthSizable". So, when I resize my > window, the resizing trickles down the hierarchy just as it should. The > CAScrollLayer resizes, each CALayer subclass instance resizes using the > custom layout manager, and layers A, B, and C all resize. The problem is > that A implicitly animates the resizing. So, as I resize the window the > instances of Layer A are all rubber-bandy rather than instantly resizing. > So, under the advice of a fellow Cocoa programmer, I attempted to use a > CATransaction with kCATransactionDisableActions turned on to make the > resizing more instantaneous. Unfortunately, this was to no avail. I've > tried applying it in all the places I could think of -- around the > height/width adjustments in my custom layout manager, within the CALayer > subclass instances' resizeSublayersWithOldSize:, within Layer > A's resizeWithOldSuperlayerSize:, and on and on. Nothing seems to work. > > Does anyone have recommendations for how to get the effect I'm looking for? > Thanks for any help! > > -Matt > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev > > > From sstevenson at mac.com Mon May 5 20:35:27 2008 From: sstevenson at mac.com (Scott Stevenson) Date: Mon May 5 20:36:17 2008 Subject: CALayer autoResizingMask In-Reply-To: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> References: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> Message-ID: <996F29D1-375B-4C9C-A8BD-F54420FB2B78@mac.com> On May 5, 2008, at 5:07 AM, Matt James wrote: > The problem is that A implicitly animates the resizing. So, as I > resize the window the > instances of Layer A are all rubber-bandy rather than instantly > resizing. You could just set a delegate for instances of LayerA and implement this in the delegate: - (id) actionForLayer:(CALayer *)layer forKey:(NSString *)event { if ([event isEqualToString:@"bounds"]) { // disable animation for new layers being added to container layer return (id)[NSNull null]; } // for everything else, use default animation. note that // nil means "default animation" in this case, not "no animation". return nil; } (I'm pretty sure the one you want is "bounds", but it might be another key) You should also add a test to the "if" condition in - actionForLayer:forKey: that checks the type of layer. You can either set a type by taking advantage of the generic KVC storage of CALayer, or just check the -className. I think the KVC approach is cleaner: LayerA* newLayer = [LayerA layer]; newLayer.delegate = self; [newLayer setValue:@"myCustomLayerTypeName" forKey:@"layerType"]; ... if ( [[layer valueForKey:@"layerType"] isEqualToString:@"myCustomLayerTypeName"] && [event isEqualToString:@"bounds"] ) Hope that helps. - Scott From sstevenson at mac.com Mon May 5 20:37:12 2008 From: sstevenson at mac.com (Scott Stevenson) Date: Mon May 5 20:37:59 2008 Subject: CALayer autoResizingMask In-Reply-To: <27cd4a440805051513u11a90a7arbce73de2f1d9fe3b@mail.gmail.com> References: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> <27cd4a440805051513u11a90a7arbce73de2f1d9fe3b@mail.gmail.com> Message-ID: On May 5, 2008, at 3:13 PM, Matt James wrote: > Hm, I hadn't heard of CATiledLayer (still fairly new to Core > Animation). > Looks interesting, though. Do you think that shifting to a > CATiledLayer > will work better? If so, what advantages does a TiledLayer have > over a > regular Layer that would aid in this issue? You typically don't want to use a CATiledLayer unless you have to. Normal CALayers have a 2048x2048 size limit inherited from the OpenGL texture size limited. CATiledLayer is a way to get around that, but they come with some limitations. - Scott From sstevenson at mac.com Mon May 5 20:39:01 2008 From: sstevenson at mac.com (Scott Stevenson) Date: Mon May 5 20:39:50 2008 Subject: CALayer autoResizingMask In-Reply-To: <996F29D1-375B-4C9C-A8BD-F54420FB2B78@mac.com> References: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> <996F29D1-375B-4C9C-A8BD-F54420FB2B78@mac.com> Message-ID: (responding to myself) On May 5, 2008, at 8:35 PM, Scott Stevenson wrote: > - (id) actionForLayer:(CALayer *)layer forKey:(NSString > *)event > { > if ([event isEqualToString:@"bounds"]) > { > // disable animation for new layers being added to container > layer > return (id)[NSNull null]; > } BTW: Ignore the comment about "new layers being added to container layer" -- it's code taken from another sample. - Scott From mattejames at gmail.com Tue May 6 09:44:22 2008 From: mattejames at gmail.com (Matt James) Date: Tue May 6 09:44:26 2008 Subject: CALayer autoResizingMask In-Reply-To: References: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> <996F29D1-375B-4C9C-A8BD-F54420FB2B78@mac.com> Message-ID: <27cd4a440805060944x4166eff6wb04808d930e8ccd1@mail.gmail.com> On Mon, May 5, 2008 at 11:39 PM, Scott Stevenson wrote: > (responding to myself) > > On May 5, 2008, at 8:35 PM, Scott Stevenson wrote: > > - (id) actionForLayer:(CALayer *)layer forKey:(NSString *)event >> { >> if ([event isEqualToString:@"bounds"]) >> { >> // disable animation for new layers being added to container layer >> return (id)[NSNull null]; >> } >> > > > > BTW: Ignore the comment about "new layers being added to container layer" > -- it's code taken from another sample. Sounds good. I'll try that tonight. When I implemented John's suggestion last night it was still a no-go. I hope I'm not omitting any important details that would be helpful in nailing down the root cause. -Matt From johnyatforums at gmail.com Tue May 6 10:43:09 2008 From: johnyatforums at gmail.com (JanakiRam) Date: Tue May 6 10:43:12 2008 Subject: C-function returning? In-Reply-To: References: Message-ID: <3f7852640805061043i14444bd8h677604399e95a46a@mail.gmail.com> It looks like the control is not comming out from the callCFunction. Are you sure whether your c function executes properly without raising any exception or not in infinite loop or generating deadlock. Try commenting the following and verify that your 'after' gets printed or not. If it prints then you can investigate the code in your C Function. * id value = callCFunction(argument); * JanakiRam. On Mon, May 5, 2008 at 3:47 AM, Christiaan Hofman wrote: > Hi list, > > I'm struggling with a very weird problem. I have a method that sort of > looks as follows: > > - (id)doSomething:(id)argument { > NSLog(@"before"); > id value = callCFunction(argument); > NSLog(@"after"); > // rest of the method > return value; > } > > I don't think it should really matter what the c-function is or the > precise method name or the rest of the implementation (right?) Anyway, when > this method is called, I see the log for "before", but not "after". So > apparently the C-function callCFunction implicitly returns! AFAIK this > should not be possible. Or am I wrong? I am totally lost. Anyone have an > idea? > > Thanks, > Christiaan > > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev > From cmhofman at gmail.com Tue May 6 13:49:13 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Tue May 6 13:49:30 2008 Subject: C-function returning? In-Reply-To: <3f7852640805061043i14444bd8h677604399e95a46a@mail.gmail.com> References: <3f7852640805061043i14444bd8h677604399e95a46a@mail.gmail.com> Message-ID: Thanks all, but I figured out that the problem was that an exception was raised in the function (I don't know the implementation of the function, I just thought I did based on sample code that was doing something equivalent as the function). For various reasons I really did not expect it to raise exceptions at all and certainly not the way it was used. Moreover, I has set a break point for [NSException raise], so i thought I excluded exceptions. But apparently that breakpoint has stopped working somewhere along the line. Christiaan On 6 May 2008, at 7:43 PM, JanakiRam wrote: > It looks like the control is not comming out from the > callCFunction. Are you sure whether your c function executes > properly without raising any exception or not in infinite loop or > generating deadlock. > > Try commenting the following and verify that your 'after' gets > printed or not. If it prints then you can investigate the code in > your C Function. > > id value = callCFunction(argument); > > JanakiRam. > > On Mon, May 5, 2008 at 3:47 AM, Christiaan Hofman > wrote: > Hi list, > > I'm struggling with a very weird problem. I have a method that sort > of looks as follows: > > - (id)doSomething:(id)argument { > NSLog(@"before"); > id value = callCFunction(argument); > NSLog(@"after"); > // rest of the method > return value; > } > > I don't think it should really matter what the c-function is or the > precise method name or the rest of the implementation (right?) > Anyway, when this method is called, I see the log for "before", but > not "after". So apparently the C-function callCFunction implicitly > returns! AFAIK this should not be possible. Or am I wrong? I am > totally lost. Anyone have an idea? > > Thanks, > Christiaan > > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev > From andrew.merenbach at ucla.edu Tue May 6 14:39:48 2008 From: andrew.merenbach at ucla.edu (Andrew Merenbach) Date: Tue May 6 14:39:55 2008 Subject: C-function returning? In-Reply-To: References: <3f7852640805061043i14444bd8h677604399e95a46a@mail.gmail.com> Message-ID: <9602090E-116E-4C4D-9E87-CECEB1E1B64D@ucla.edu> Hi, Christiaan, You may consider setting a breakpoint on objc_exception_throw instead of -[NSException raise], since the former is more of a catch-all, at least in Leopard (my understanding is that -[NSException raise] now calls objc_exception_throw -- but please, someone correct me if I'm wrong?). Cheers, Andrew On May 6, 2008, at 1:49 PM, Christiaan Hofman wrote: > Thanks all, but I figured out that the problem was that an exception > was raised in the function (I don't know the implementation of the > function, I just thought I did based on sample code that was doing > something equivalent as the function). For various reasons I really > did not expect it to raise exceptions at all and certainly not the > way it was used. Moreover, I has set a break point for [NSException > raise], so i thought I excluded exceptions. But apparently that > breakpoint has stopped working somewhere along the line. > > Christiaan > > On 6 May 2008, at 7:43 PM, JanakiRam wrote: > >> It looks like the control is not comming out from the >> callCFunction. Are you sure whether your c function executes >> properly without raising any exception or not in infinite loop or >> generating deadlock. >> >> Try commenting the following and verify that your 'after' gets >> printed or not. If it prints then you can investigate the code in >> your C Function. >> >> id value = callCFunction(argument); >> >> JanakiRam. >> >> On Mon, May 5, 2008 at 3:47 AM, Christiaan Hofman >> wrote: >> Hi list, >> >> I'm struggling with a very weird problem. I have a method that sort >> of looks as follows: >> >> - (id)doSomething:(id)argument { >> NSLog(@"before"); >> id value = callCFunction(argument); >> NSLog(@"after"); >> // rest of the method >> return value; >> } >> >> I don't think it should really matter what the c-function is or the >> precise method name or the rest of the implementation (right?) >> Anyway, when this method is called, I see the log for "before", but >> not "after". So apparently the C-function callCFunction implicitly >> returns! AFAIK this should not be possible. Or am I wrong? I am >> totally lost. Anyone have an idea? >> >> Thanks, >> Christiaan >> >> _______________________________________________ >> MacOSX-dev mailing list >> MacOSX-dev@omnigroup.com >> http://www.omnigroup.com/mailman/listinfo/macosx-dev >> > > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev From mattejames at gmail.com Wed May 7 04:20:05 2008 From: mattejames at gmail.com (Matt James) Date: Wed May 7 04:20:09 2008 Subject: CALayer autoResizingMask In-Reply-To: <27cd4a440805060944x4166eff6wb04808d930e8ccd1@mail.gmail.com> References: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> <996F29D1-375B-4C9C-A8BD-F54420FB2B78@mac.com> <27cd4a440805060944x4166eff6wb04808d930e8ccd1@mail.gmail.com> Message-ID: <27cd4a440805070420hacfd640k159a8cee76666d9a@mail.gmail.com> On Tue, May 6, 2008 at 12:44 PM, Matt James wrote: > On May 5, 2008, at 8:35 PM, Scott Stevenson wrote: >> >> - (id) actionForLayer:(CALayer *)layer forKey:(NSString *)event >>> { >>> if ([event isEqualToString:@"bounds"]) >>> { >>> // disable animation for new layers being added to container layer >>> return (id)[NSNull null]; >>> } >> >> > Sounds good. I'll try that tonight. When I implemented John's suggestion > last night it was still a no-go. I hope I'm not omitting any important > details that would be helpful in nailing down the root cause. > Still no luck with it -- no matter what, I can't seem to get those instances of Layer A to stop implicitly animating. I'll keep playing with it and see if any new details emerge that would explain why these suggestions haven't worked. Thanks again guys! -Matt From mattejames at gmail.com Wed May 7 04:35:29 2008 From: mattejames at gmail.com (Matt James) Date: Wed May 7 04:35:32 2008 Subject: CALayer autoResizingMask In-Reply-To: <27cd4a440805070420hacfd640k159a8cee76666d9a@mail.gmail.com> References: <27cd4a440805050507t6927b891td86561f928369e84@mail.gmail.com> <996F29D1-375B-4C9C-A8BD-F54420FB2B78@mac.com> <27cd4a440805060944x4166eff6wb04808d930e8ccd1@mail.gmail.com> <27cd4a440805070420hacfd640k159a8cee76666d9a@mail.gmail.com> Message-ID: <27cd4a440805070435y34a84ddcu11fca132c2134e68@mail.gmail.com> On Wed, May 7, 2008 at 7:20 AM, Matt James wrote: > Still no luck with it -- no matter what, I can't seem to get those > instances of Layer A to stop implicitly animating. I'll keep playing with > it and see if any new details emerge that would explain why these > suggestions haven't worked. Thanks again guys! > Ah, excellent! I'm not sure why the other solutions didn't work, but I found something that does the trick. Since my main concern is the implicit animation of those layers when the window resizes, I took advantage of 2 window delegate methods, windowWillResize:toSize: and windowDidResize. I ended up beginning my CATransaction in the former, and committing it in the latter which works great. Only one more small glitch, but I think I can take care of that on my own. Thanks again for all the help! -Matt From gsslist+osxdev at anthropohedron.net Wed May 7 14:32:54 2008 From: gsslist+osxdev at anthropohedron.net (Gregory Seidman) Date: Wed May 7 14:34:38 2008 Subject: Understanding reference count ownership Message-ID: <20080507213252.GA6101@anthropohedron.net> I'm coming across this in iPhone development, but it is just Cocoa and comes up in any Objective-C context without garbage collection. I think I understand the "Create Rule" where any time you alloc or call a method with "create" in the name you are responsible for one reference count. What I'm less clear on is various factory-like methods. For example: NSString *foo = [NSString stringWithFormat:@"%d times", 6]; Does the calling code now own a reference count of foo? How about: NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL urlWithString:@"http://google.com"]]; Did the NSURL object just leak? For that matter: NSString *bar = @"bar"; Does bar now have a reference count I have to decrement before it leaves scope? I'm just a little unsure of what is handled for me and what I have to handle manually. I've already been bitten by autoreleasing stuff that I thought I owned, so I'm erring on the side of leaking memory. Of course, that's a bad plan for any app and particularly on the iPhone. --Greg From cmhofman at gmail.com Wed May 7 14:47:05 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Wed May 7 14:47:13 2008 Subject: Understanding reference count ownership In-Reply-To: <20080507213252.GA6101@anthropohedron.net> References: <20080507213252.GA6101@anthropohedron.net> Message-ID: <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> On 7 May 2008, at 11:32 PM, Gregory Seidman wrote: > I'm coming across this in iPhone development, but it is just Cocoa and > comes up in any Objective-C context without garbage collection. > > I think I understand the "Create Rule" where any time you alloc or > call a > method with "create" in the name you are responsible for one reference > count. What I'm less clear on is various factory-like methods. For > example: > > NSString *foo = [NSString stringWithFormat:@"%d times", 6]; > > Does the calling code now own a reference count of foo? How about: > > NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL > urlWithString:@"http://google.com"]]; > > Did the NSURL object just leak? For that matter: > > NSString *bar = @"bar"; > > Does bar now have a reference count I have to decrement before it > leaves > scope? > > I'm just a little unsure of what is handled for me and what I have to > handle manually. I've already been bitten by autoreleasing stuff > that I > thought I owned, so I'm erring on the side of leaking memory. Of > course, > that's a bad plan for any app and particularly on the iPhone. > > --Greg No. The rule is that only methods containing "create", "copy", and "alloc" in their name implicitly retain. Class factory methods return an autoreleased object, which effectively has retain count 0. Think of autorelease as release, so effectively it reduces the retain count by 1. It just releases delayed. Similarly for constant strings like @"bar" (these are just static strings that stay around, but are not explicitly retained). Christiaan From joar at joar.com Wed May 7 14:47:38 2008 From: joar at joar.com (j o a r) Date: Wed May 7 14:47:41 2008 Subject: Understanding reference count ownership In-Reply-To: <20080507213252.GA6101@anthropohedron.net> References: <20080507213252.GA6101@anthropohedron.net> Message-ID: <20C98EC8-71C4-4503-B403-0E7B4BE67AA5@joar.com> On May 7, 2008, at 2:32 PM, Gregory Seidman wrote: > I'm just a little unsure of what is handled for me and what I have to > handle manually. I've already been bitten by autoreleasing stuff > that I > thought I owned, so I'm erring on the side of leaking memory. Of > course, > that's a bad plan for any app and particularly on the iPhone. The rules are really very straight forward once you spend a little time in this environment. Don't worry, you will probably "get it" any day now, and after that it's not something you ever have to think twice about. Have a look at the end of this page: The rules outlined there should answer all of the questions that you posted here. If not, please return to the list with a follow up. j o a r From jim.correia at pobox.com Wed May 7 14:49:52 2008 From: jim.correia at pobox.com (Jim Correia) Date: Wed May 7 14:49:59 2008 Subject: Understanding reference count ownership In-Reply-To: <20080507213252.GA6101@anthropohedron.net> References: <20080507213252.GA6101@anthropohedron.net> Message-ID: On May 7, 2008, at 5:32 PM, Gregory Seidman wrote: > I'm coming across this in iPhone development, but it is just Cocoa and > comes up in any Objective-C context without garbage collection. > > I think I understand the "Create Rule" where any time you alloc or > call a > method with "create" in the name you are responsible for one reference > count. The documentation is complete. It lists all the situations in which you are responsible for releasing an object when you are done with it. In all other situations, it is not your responsibility to release it. > What I'm less clear on is various factory-like methods. For example: > > NSString *foo = [NSString stringWithFormat:@"%d times", 6]; > > Does the calling code now own a reference count of foo? How about: > > NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL > urlWithString:@"http://google.com"]]; > > Did the NSURL object just leak? Those fall under the "not your responsibility to release the object" cases. The objects will typically be autoreleased by the "factory" method, but that's an implementation detail you don't need to worry about. (The objects could have come from some magical object forest, for all you care.) The only thing you need to know is should I release this when I'm done with it, and/or do I need to retain this if I want to hold onto it for awhile. Jim From mmalc-lists at mmalc.com Wed May 7 16:34:25 2008 From: mmalc-lists at mmalc.com (mmalc Crawford) Date: Wed May 7 16:49:35 2008 Subject: Understanding reference count ownership In-Reply-To: <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> Message-ID: <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> On May 7, 2008, at 2:47 PM, Christiaan Hofman wrote: > No. The rule is that only methods containing "create", "copy", and > "alloc" in their name implicitly retain. > No, this is wrong. This is why people are typically discouraged from repeating memory management rules on lists and instead encouraged to point developers to the simple straightforward rules given in the documentation -- as illustrated by Joar's reply. mmalc From psarge at gmail.com Thu May 8 06:16:42 2008 From: psarge at gmail.com (Paul Sargent) Date: Thu May 8 06:16:46 2008 Subject: Understanding reference count ownership In-Reply-To: <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> Message-ID: <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> On Thu, May 8, 2008 at 12:34 AM, mmalc Crawford wrote: > > On May 7, 2008, at 2:47 PM, Christiaan Hofman wrote: > > No. The rule is that only methods containing "create", "copy", and "alloc" >> in their name implicitly retain. >> >> No, this is wrong. I have to say, even with a link to the documentation, that statement just makes me more confused. I'm not sure what it is you're objecting to. Is it that objects returned by those methods haven't been [retain]'d, they just haven't been [autorelease]'d? From cmhofman at gmail.com Thu May 8 06:32:24 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Thu May 8 06:32:34 2008 Subject: Understanding reference count ownership In-Reply-To: <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> Message-ID: <5F81DD95-3CE9-4081-9E23-CDE2BCA45519@gmail.com> On 8 May 2008, at 3:16 PM, Paul Sargent wrote: > On Thu, May 8, 2008 at 12:34 AM, mmalc Crawford lists@mmalc.com> > wrote: > >> >> On May 7, 2008, at 2:47 PM, Christiaan Hofman wrote: >> >> No. The rule is that only methods containing "create", "copy", and >> "alloc" >>> in their name implicitly retain. >>> >>> No, this is wrong. > > > I have to say, even with a link to the documentation, that statement > just > makes me more confused. I'm not sure what it is you're objecting to. > > Is it that objects returned by those methods haven't been > [retain]'d, they > just haven't been [autorelease]'d? I know, because I know what gets me confused. It's not "create" but "new". The confusion is partly due to the OP (who listed it as the part he said he understands), and partly due to Carbon, as there the similar keywords are "Copy" and "Create". IMHO, I think the "new" rule was a mistake, because it's confusing (given the Carbon rule), and moreover it is rather an exception than a rule (I've never used it, and I know only a single example in Cocoa, which is an utterly expendable). Also note that the documentation is not sacred, as it has exceptions (which are not mentioned in the ownership docs AFAICS). Christiaan Christiaan From mmalc-lists at mmalc.com Thu May 8 07:55:57 2008 From: mmalc-lists at mmalc.com (mmalc Crawford) Date: Thu May 8 07:56:02 2008 Subject: Understanding reference count ownership In-Reply-To: <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> Message-ID: <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> On May 8, 2008, at 6:16 AM, Paul Sargent wrote: >>> No. The rule is that only methods containing "create", "copy", and >>> "alloc" in their name implicitly retain. >> >> No, this is wrong. > > I have to say, even with a link to the documentation, that statement > just makes me more confused. I'm not sure what it is you're > objecting to. > Even a cursory glance at the documentation should reveal that the "rule" given in the original message is not the same as that given in the documentation: "You take ownership of an object if you create it using a method whose name begins with ?alloc? or ?new? or contains ?copy? (for example, alloc, newObject, or mutableCopy), or if you send it a retain message." On May 8, 2008, at 6:32 AM, Christiaan Hofman wrote: > I know, because I know what gets me confused. It's not "create" but > "new". The confusion is partly due to the OP (who listed it as the > part he said he understands), and partly due to Carbon, as there the > similar keywords are "Copy" and "Create". > And (used as a modifier to your original post) that's still wrong -- see above. > IMHO, I think the "new" rule was a mistake, because it's confusing > (given the Carbon rule), and moreover it is rather an exception than > a rule (I've never used it, and I know only a single example in > Cocoa, which is an utterly expendable). > The "new" rule considerably predates Carbon. There are several examples, as a trivial search in Xcode for example will reveal. Moreover, it allows for a useful general pattern. If you want to specify a "convenience constructor" that returns an object that the caller owns, then you can prepend "new" to the method name. This has particular value if you want to avoid autorelease. > Also note that the documentation > is not sacred, as it has exceptions (which are not mentioned in > the ownership docs AFAICS). > As a fundamental set of rules, they are "sacred". Such rare exceptions as there are are called out in the documentation where appropriate. mmalc From cmhofman at gmail.com Thu May 8 08:16:25 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Thu May 8 08:16:36 2008 Subject: Understanding reference count ownership In-Reply-To: <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> Message-ID: <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> On 8 May 2008, at 4:55 PM, mmalc Crawford wrote: > > On May 8, 2008, at 6:16 AM, Paul Sargent wrote: > >>>> No. The rule is that only methods containing "create", "copy", >>>> and "alloc" in their name implicitly retain. >>> >>> No, this is wrong. >> >> I have to say, even with a link to the documentation, that >> statement just makes me more confused. I'm not sure what it is >> you're objecting to. >> > Even a cursory glance at the documentation should reveal that the > "rule" given in the original message is not the same as that given > in the documentation: > > "You take ownership of an object if you create it using a method > whose name begins with ?alloc? or ?new? or contains ?copy? (for > example, alloc, newObject, or mutableCopy), or if you send it a > retain message." > Sure, but that's not what I'm saying. I don't disagree that I was wrong and too quick to answer. I'm just explaining what led me to this confusion. Also this very sentence is a case in point: here and at several p[laces in these docs the word "create" is used to describe making an object that you own. So it's at least counter-intuitive to use the word "new" to indicate it in a method name. > > > On May 8, 2008, at 6:32 AM, Christiaan Hofman wrote: >> I know, because I know what gets me confused. It's not "create" but >> "new". The confusion is partly due to the OP (who listed it as the >> part he said he understands), and partly due to Carbon, as there >> the similar keywords are "Copy" and "Create". >> > And (used as a modifier to your original post) that's still wrong -- > see above. > It's the main point. And the part about begins and contains is at least partly wrong (-initWithArray:copyItems: would implicitly retain according to this sentence). And "retain" should be just obvious to anyone. This is just nitpicking. And again I was just explaining the source of confusion. > >> IMHO, I think the "new" rule was a mistake, because it's confusing >> (given the Carbon rule), and moreover it is rather an exception >> than a rule (I've never used it, and I know only a single example >> in Cocoa, which is an utterly expendable). >> > The "new" rule considerably predates Carbon. There are several > examples, as a trivial search in Xcode for example will reveal. > Moreover, it allows for a useful general pattern. If you want to > specify a "convenience constructor" that returns an object that the > caller owns, then you can prepend "new" to the method name. This > has particular value if you want to avoid autorelease. > I know. I'm just saying that in hindsight, I truly believe that "create" would have been far more appropriate and intuitive, and moreover, more consistent, because of the Carbon rule as it is also a verb, like allocate, copy, retain. Again,. I'm explaining my source of confusion. > >> Also note that the documentation > > is not sacred, as it has exceptions (which are not mentioned in >> the ownership docs AFAICS). >> > As a fundamental set of rules, they are "sacred". Such rare > exceptions as there are are called out in the documentation where > appropriate. > > mmalc > E.g. initWithObjects:copyItems:. I couldn't find it in the ownership management docs, nor in the description of the method itself. In fact, that description might make you believe that the objects from the array are copied, and therefore should be released by you! Christiaan From joar at joar.com Thu May 8 08:30:54 2008 From: joar at joar.com (j o a r) Date: Thu May 8 08:30:56 2008 Subject: Understanding reference count ownership In-Reply-To: <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> Message-ID: <3F95A976-A3B2-4A78-9DE3-84E2E93BF698@joar.com> On May 8, 2008, at 8:16 AM, Christiaan Hofman wrote: > Sure, but that's not what I'm saying. I don't disagree that I was > wrong and too quick to answer. I'm just explaining what led me to > this confusion. Also this very sentence is a case in point: here and > at several p[laces in these docs the word "create" is used to > describe making an object that you own. So it's at least counter- > intuitive to use the word "new" to indicate it in a method name. It might possibly be a bit confusing that "create" is a memory management keyword in CoreFoundation, but the documentation should never be mixed up on that topic. > E.g. initWithObjects:copyItems:. I couldn't find it in the ownership > management docs, nor in the description of the method itself. In > fact, that description might make you believe that the objects from > the array are copied, and therefore should be released by you! Whenever you find specific places where the existing documentation is incorrect, or where additional documentation is required, please file bug reports / enhancement requests: j o a r From sherm.pendley at gmail.com Thu May 8 08:50:28 2008 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Thu May 8 08:50:31 2008 Subject: Understanding reference count ownership In-Reply-To: <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> Message-ID: On Thu, May 8, 2008 at 11:16 AM, Christiaan Hofman wrote: E.g. initWithObjects:copyItems:. I couldn't find it in the ownership > management docs, nor in the description of the method itself. There's no special mention in the method docs, because none is needed - the general rules apply to this method as-is. > In fact, that description might make you believe that the objects from the > array are copied, and therefore should be released by you! If the array calls -copy on the items that you've added, then *it* is responsible for balancing that -copy, *not you* - just like always. You didn't send the -copy message, so you are not responsible for balancing it. The inside of another object is Las Vegas - what happens there, stays there. Trying to balance code other than your own is what gets a lot of newbies into deep confusion. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net From cmhofman at gmail.com Thu May 8 09:09:31 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Thu May 8 09:09:40 2008 Subject: Understanding reference count ownership In-Reply-To: References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> Message-ID: <21E918F3-8C9C-4DFF-978D-F218932076C0@gmail.com> On 8 May 2008, at 5:50 PM, Sherm Pendley wrote: > On Thu, May 8, 2008 at 11:16 AM, Christiaan Hofman > wrote: > > E.g. initWithObjects:copyItems:. I couldn't find it in the ownership > management docs, nor in the description of the method itself. > > There's no special mention in the method docs, because none is > needed - the general rules apply to this method as-is. > The sentence I linked to and mmalc quoted clearly says 'contains "copy"', and this method name obviously contains the word "copy". > In fact, that description might make you believe that the objects > from the array are copied, and therefore should be released by you! > > If the array calls -copy on the items that you've added, then *it* > is responsible for balancing that -copy, *not you* - just like > always. You didn't send the -copy message, so you are not > responsible for balancing it. The inside of another object is Las > Vegas - what happens there, stays there. Trying to balance code > other than your own is what gets a lot of newbies into deep confusion. > > sherm-- > > -- > Cocoa programming in Perl: http://camelbones.sourceforge.net Notice that I'm using the word "might"; what I'm saying here is that the description is not as clear as it could be. But the main point is what I said above, which would imply that the created array has an extra implicit retain (which of course is not true). And the documentation of this method does not explicitly say that's not the case. I think the docs should say 'begins with "alloc", "new", "copy", or "mutableCopy". Or is there an exception to that? Christiaan From sherm.pendley at gmail.com Thu May 8 09:28:25 2008 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Thu May 8 09:28:28 2008 Subject: Understanding reference count ownership In-Reply-To: <21E918F3-8C9C-4DFF-978D-F218932076C0@gmail.com> References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> <21E918F3-8C9C-4DFF-978D-F218932076C0@gmail.com> Message-ID: On Thu, May 8, 2008 at 12:09 PM, Christiaan Hofman wrote: > > On 8 May 2008, at 5:50 PM, Sherm Pendley wrote: > > On Thu, May 8, 2008 at 11:16 AM, Christiaan Hofman > wrote: > > E.g. initWithObjects:copyItems:. I couldn't find it in the ownership >> management docs, nor in the description of the method itself. > > > There's no special mention in the method docs, because none is needed - the > general rules apply to this method as-is. > > The sentence I linked to and mmalc quoted clearly says 'contains "copy"', > and this method name obviously contains the word "copy". > The linked-to sentence says "if you create it using a method whose name begins with "alloc" or "new" or contains "copy"". You created the array object with +alloc, and then sent it an -initWithObjects:copyItems. Notice that I'm using the word "might"; what I'm saying here is that the > description is not as clear as it could be. > It's crystal clear. You're not creating an object; you did that with +alloc. What you're doing with -initWithObjects:copyItems is sending a message to an existing object. So whether that message has "copy" in its name is completely irrelevant to memory management. > But the main point is what I said above, which would imply that the created > array has an extra implicit retain > The -initWithObjects:copyItems: method doesn't create a new object, so the presence of "copy" in its name implies no such thing. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net From cmhofman at gmail.com Thu May 8 09:48:16 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Thu May 8 09:48:24 2008 Subject: Understanding reference count ownership In-Reply-To: References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> <21E918F3-8C9C-4DFF-978D-F218932076C0@gmail.com> Message-ID: On 8 May 2008, at 6:28 PM, Sherm Pendley wrote: > On Thu, May 8, 2008 at 12:09 PM, Christiaan Hofman > wrote: > > On 8 May 2008, at 5:50 PM, Sherm Pendley wrote: >> On Thu, May 8, 2008 at 11:16 AM, Christiaan Hofman > > wrote: >> >> E.g. initWithObjects:copyItems:. I couldn't find it in the >> ownership management docs, nor in the description of the method >> itself. >> >> There's no special mention in the method docs, because none is >> needed - the general rules apply to this method as-is. > The sentence I linked to and mmalc quoted clearly says 'contains > "copy"', and this method name obviously contains the word "copy". > > The linked-to sentence says "if you create it using a method whose > name begins with "alloc" or "new" or contains "copy"". You created > the array object with +alloc, and then sent it an - > initWithObjects:copyItems. > That depends on what "create" means. In the docs this is defined circular. This is how it is defined in the docs (Object Ownership Policy): You "create" an object using a method whose name begins with ?alloc? or ?new? or contains ?copy? (for example, alloc, newObject, or mutableCopy). > Notice that I'm using the word "might"; what I'm saying here is that > the description is not as clear as it could be. > > It's crystal clear. No, it's not. > You're not creating an object; you did that with +alloc. What you're > doing with -initWithObjects:copyItems is sending a message to an > existing object. So whether that message has "copy" in its name is > completely irrelevant to memory management. > In fact a new instance *is* created in this particular example, to replace the temporary receiver (though not by you, but internally by the class). So there is a reason for an argument. It would have been crystal clear if "class method" was used in both sentences, instead of just "method". Then the definition of "create" would have been unambiguous. Now it's not. > But the main point is what I said above, which would imply that the > created array has an extra implicit retain > > The -initWithObjects:copyItems: method doesn't create a new object, > so the presence of "copy" in its name implies no such thing. > > sherm-- Can't find that part of the definition in the docs. Anyway, this discussion is turning too philosophical, it's better to terminate, because we all know exactly what is meant. Christiaan From sherm.pendley at gmail.com Thu May 8 10:16:16 2008 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Thu May 8 10:16:21 2008 Subject: Understanding reference count ownership In-Reply-To: References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> <21E918F3-8C9C-4DFF-978D-F218932076C0@gmail.com> Message-ID: On Thu, May 8, 2008 at 12:48 PM, Christiaan Hofman wrote: > > On 8 May 2008, at 6:28 PM, Sherm Pendley wrote: > > On Thu, May 8, 2008 at 12:09 PM, Christiaan Hofman > wrote: > >> >> On 8 May 2008, at 5:50 PM, Sherm Pendley wrote: >> >> On Thu, May 8, 2008 at 11:16 AM, Christiaan Hofman >> wrote: >> >> E.g. initWithObjects:copyItems:. I couldn't find it in the ownership >>> management docs, nor in the description of the method itself. >> >> >> There's no special mention in the method docs, because none is needed - >> the general rules apply to this method as-is. >> >> The sentence I linked to and mmalc quoted clearly says 'contains "copy"', >> and this method name obviously contains the word "copy". >> > > The linked-to sentence says "if you create it using a method whose name > begins with "alloc" or "new" or contains "copy"". You created the array > object with +alloc, and then sent it an -initWithObjects:copyItems. > > That depends on what "create" means. > Spare me. This isn't politics, and you aren't Bill Clinton. You know perfectly well what create means, and you know perfectly well that sending a message to an existing object does not create the object. > Anyway, this discussion is turning too philosophical, it's better to > terminate, because we all know exactly what is meant. > Precisely my point. Newbies tend to get philosophical, debate about the precise meaning of the word "create," whether a -retain in some other code must be balanced by their own code, etc. It's all this exploring of hypothetical edge cases and exceptions that complicate things; the rules themselves are quite simple and very consistent. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net From mattejames at gmail.com Fri May 9 20:44:55 2008 From: mattejames at gmail.com (Matt James) Date: Fri May 9 20:44:58 2008 Subject: NSLog every selector on an object? Message-ID: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> Is there any way to overload a class in such a manner as to print out every method call it makes at any given time before it runs the method? Right now, I'm overloading a few methods of this particular class and putting NSLog's at the first line, but I was wondering if there was a way to jump in before _ALL_ methods on an object and perform this particular task. Thanks for any help! -Matt From cmhofman at gmail.com Sat May 10 04:11:21 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Sat May 10 04:11:35 2008 Subject: NSLog every selector on an object? In-Reply-To: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> Message-ID: On 10 May 2008, at 5:44 AM, Matt James wrote: > Is there any way to overload a class in such a manner as to print > out every > method call it makes at any given time before it runs the method? > Right > now, I'm overloading a few methods of this particular class and > putting > NSLog's at the first line, but I was wondering if there was a way to > jump in > before _ALL_ methods on an object and perform this particular task. > Thanks for any help! > > -Matt No, not really. The class does not send the message, it essentially is just a data structure containing the class info (like its methods). This is what happens when calling a method (through objc_msgSend): - get class of object - lookup method for selector in class - get implementation of method - execute implementation Read the runtime docs for a more detailed (and more correct) description. The lookup steps just lookup in the data structure, and the implementations contain nothing generic, they are just separate functions. So the only thing that's called for every method call is objc_msgSend (or objc_msgSensSuper). So you'd need to replace those functions... (not that I'm saying you should, of course). Having said this, well I guess there is a dirty and complicated way using isa-swizzling, replacing the class of the objects with a dynamically generated class that either copies the methods of the original class or somehow 'forwards' methods to the original class. This is sort of what binding support does to send KVO notifications, though I don't know the details. Christiaan From me at JonathonMah.com Sat May 10 06:49:09 2008 From: me at JonathonMah.com (Jonathon Mah) Date: Sat May 10 06:49:22 2008 Subject: NSLog every selector on an object? In-Reply-To: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> Message-ID: <10169FDF-2C0C-4608-9301-A17762AC625E@JonathonMah.com> Hi Matt, On 2008-05-10, at 13:14, Matt James wrote: > Is there any way to overload a class in such a manner as to print > out every > method call it makes at any given time before it runs the method? You could probably use a variation on this: If you wanted to trace messages to a specific /object/, you could probably store its address in a global somewhere, and use that instead of the test for a nil receiver. As for tracing messages to all instances of a /class/... Well, I'd have to learn dtrace. Of course, if you wanted a simpler, pragmatic solution you could write a macro to generate your logging code. @implementation MyClassLogging LOG( (void)msgA ) LOG( (int)msg2:(id)arg ) @end Jonathon Mah me@JonathonMah.com From georg.seifert at gmx.de Sat May 10 08:16:08 2008 From: georg.seifert at gmx.de (Georg Seifert) Date: Sat May 10 08:16:29 2008 Subject: NSCollectionView caching Message-ID: Hello, I use a NSCollectionView. The itemPrototype contains a NSImageView and two text fields. I bind to a NSArrayController (wich controlles a array of custom objects with properties for an NSImage and some NSStrings). This Controller is filtered with predicates. Every time I remove the predicate, the collection view will generate all the item views again and even with 200 entries this is awfully slow (on my PowerBook 1.67GHz). How I can save the item views and just hide/reuse them? Or is there any other way to speed things up? Thanks Georg From cmhofman at gmail.com Sat May 10 08:20:54 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Sat May 10 08:21:00 2008 Subject: Understanding reference count ownership In-Reply-To: References: <20080507213252.GA6101@anthropohedron.net> <9D471713-8BA5-491B-88CF-8E03307EA3D6@gmail.com> <551AA7D3-1BA6-4CE6-BC79-F2BFE47BF3A6@mmalc.com> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> <21E918F3-8C9C-4DFF-978D-F218932076C0@gmail.com> Message-ID: <76CCAC75-5467-44F3-8356-2812CB31E6C0@gmail.com> On 8 May 2008, at 7:16 PM, Sherm Pendley wrote: > On Thu, May 8, 2008 at 12:48 PM, Christiaan Hofman > wrote: > > On 8 May 2008, at 6:28 PM, Sherm Pendley wrote: > >> On Thu, May 8, 2008 at 12:09 PM, Christiaan Hofman > > wrote: >> >> On 8 May 2008, at 5:50 PM, Sherm Pendley wrote: >>> On Thu, May 8, 2008 at 11:16 AM, Christiaan Hofman >> > wrote: >>> >>> E.g. initWithObjects:copyItems:. I couldn't find it in the >>> ownership management docs, nor in the description of the method >>> itself. >>> >>> There's no special mention in the method docs, because none is >>> needed - the general rules apply to this method as-is. >> The sentence I linked to and mmalc quoted clearly says 'contains >> "copy"', and this method name obviously contains the word "copy". >> >> The linked-to sentence says "if you create it using a method whose >> name begins with "alloc" or "new" or contains "copy"". You created >> the array object with +alloc, and then sent it an - >> initWithObjects:copyItems. > That depends on what "create" means. > > Spare me. This isn't politics, and you aren't Bill Clinton. You know > perfectly well what create means, and you know perfectly well that > sending a message to an existing object does not create the object. Apologies, but I have to respond to this. Seriously, I am not Bill Clinton, and I do *not* know what "create" means in this sentence. And I know perfectly well that sending a message to an existing object *can* create an object: -copy generally does, and I happen to know that this particular initializer *does* create a new object to replace the receiver (which is a temporary object). But those are implementation details, and implementation details should not matter. Personally, I'd say that +array creates a new object. However the docs say it doesn't. > > > Anyway, this discussion is turning too philosophical, it's better to > terminate, because we all know exactly what is meant. > > Precisely my point. Newbies tend to get philosophical, debate about > the precise meaning of the word "create," whether a -retain in some > other code must be balanced by their own code, etc. Exactly, that's why the word "create" should not be in this sentence of the docs or at least it's meaning should not be decisive about ownership. > It's all this exploring of hypothetical edge cases and exceptions > that complicate things; the rules themselves are quite simple and > very consistent. > > sherm-- I disagree. It's exploring the edge cases that clarifies the meaning of things and exposes shortcomings in formulation. You agree reading between the lines, and I'm saying that the docs should be clear about such a fundamental point, without the need to read between the lines or using English grammar rules. I could give you many examples where the rules in the doc would give me the wrong answer. But I'll leave that for my bug report. Christiaan From cmhofman at gmail.com Sat May 10 08:47:29 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Sat May 10 08:47:36 2008 Subject: NSCollectionView caching In-Reply-To: References: Message-ID: <65CC792A-8112-4ED1-84F4-68659ADD53BE@gmail.com> On 10 May 2008, at 5:16 PM, Georg Seifert wrote: > Hello, > > I use a NSCollectionView. The itemPrototype contains a NSImageView > and two text fields. > > I bind to a NSArrayController (wich controlles a array of custom > objects with properties for an NSImage and some NSStrings). > This Controller is filtered with predicates. Every time I remove the > predicate, the collection view will generate all the item views > again and even with 200 entries this is awfully slow (on my > PowerBook 1.67GHz). > > How I can save the item views and just hide/reuse them? Or is there > any other way to speed things up? > > Thanks > Georg I think you should override -newItemForRepresentedObject:. However the caching logic (e.g. when to dispose of them) could depend on your exact model. In a similar situation (displaying views in a table in a Tiger- compatible app) I had a view contained by the represented object. This makes it easy to have unique items, and they are properly disposed of when the object gets removed. You could do something like this: - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object { id item = [object item]; if (item == nil) { item = [super newItemForRepresentedObject:object]; [object setItem:item]; } else { [item retain]; } return item; } Warning: beware for retainment cycles if you're not careful. Christiaan From chad+macosx at objectwerks.com Sat May 10 09:32:31 2008 From: chad+macosx at objectwerks.com (objectwerks inc) Date: Sat May 10 09:32:36 2008 Subject: NSLog every selector on an object? In-Reply-To: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> Message-ID: On May 9, 2008, at 9:44 PM, Matt James wrote: > Is there any way to overload a class in such a manner as to print > out every > method call it makes at any given time before it runs the method? > Right > now, I'm overloading a few methods of this particular class and > putting > NSLog's at the first line, but I was wondering if there was a way to > jump in > before _ALL_ methods on an object and perform this particular task. > Thanks for any help! See if you can do anything with -messageSignatureForSelector:(SEL) and -forwardInvocation: and that family of stuff as defined on NSObject. You may be able to figure something out there. It has been a while since I did anything with it but there are hooks that maybe you can use to find out what is going to be called and do your thing then Chad > > > -Matt > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev From bbum at mac.com Sat May 10 10:48:00 2008 From: bbum at mac.com (Bill Bumgarner) Date: Sat May 10 10:48:59 2008 Subject: NSLog every selector on an object? In-Reply-To: References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> Message-ID: <664B359C-DDA2-4950-A2E4-F5FA938D7959@mac.com> > On May 9, 2008, at 9:44 PM, Matt James wrote: >> Is there any way to overload a class in such a manner as to print >> out every >> method call it makes at any given time before it runs the method? >> Right >> now, I'm overloading a few methods of this particular class and >> putting >> NSLog's at the first line, but I was wondering if there was a way >> to jump in >> before _ALL_ methods on an object and perform this particular task. >> Thanks for any help! You could implement an NSProxy type thing and shove that in the middle. Or diddle the isa of the class to point to a new isa that logs-and-forwards via various mechanisms described within the previous messages (including the link to my weblog, which definitely could be hacked to do this). Personally, I'd use dtrace. I wrote up a couple of later articles on logging / debugging messages to nil. http://www.friday.com/bbum/2008/01/03/objective-c-using-dtrace-to-trace-messages-to-nil/ http://www.friday.com/bbum/2008/01/26/objective-c-printing-class-name-from-dtrace/ You would want to change the '/arg0==0/' qualifier to qualify for your instance of interest. This will be just a bit non-trivial to do compared to the described recipes. You'll need to stash the id of the object of interest into dtrace's world somehow. You could do so with a BEGIN{} hook, but that'll require firing up the dtrace script *after* the object has come into existence. A better solution might be to have a couple of dtrace trace points in the script; one that does the qualified logging and one that, when triggered, stashes away an object of interest's id such that the qualifier can see it. b.bum From sherm.pendley at gmail.com Sat May 10 10:58:29 2008 From: sherm.pendley at gmail.com (Sherm Pendley) Date: Sat May 10 10:58:31 2008 Subject: Understanding reference count ownership In-Reply-To: <76CCAC75-5467-44F3-8356-2812CB31E6C0@gmail.com> References: <20080507213252.GA6101@anthropohedron.net> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> <21E918F3-8C9C-4DFF-978D-F218932076C0@gmail.com> <76CCAC75-5467-44F3-8356-2812CB31E6C0@gmail.com> Message-ID: On Sat, May 10, 2008 at 11:20 AM, Christiaan Hofman wrote: > > On 8 May 2008, at 7:16 PM, Sherm Pendley wrote: > > On Thu, May 8, 2008 at 12:48 PM, Christiaan Hofman > wrote: > >> >> On 8 May 2008, at 6:28 PM, Sherm Pendley wrote: >> >> The linked-to sentence says "if you create it using a method whose name >> begins with "alloc" or "new" or contains "copy"". You created the array >> object with +alloc, and then sent it an -initWithObjects:copyItems. >> >> That depends on what "create" means. >> > > Spare me. This isn't politics, and you aren't Bill Clinton. You know > perfectly well what create means, and you know perfectly well that sending a > message to an existing object does not create the object. > > Apologies, but I have to respond to this. > > Seriously, I am not Bill Clinton, and I do *not* know what "create" means > in this sentence. And I know perfectly well that sending a message to an > existing object *can* create an object: -copy generally does, and I happen > to know that this particular initializer *does* create a new object to > replace the receiver (which is a temporary object). But those are > implementation details, and implementation details should not matter. > Personally, I'd say that +array creates a new object. However the docs say > it doesn't. > They say no such thing. Again - you are far, far over-thinking this. The memory-management docs we're referring to here list a few object creation methods that imply a particular responsibility with respect to memory management. The list is not an exhaustive list of every object creation method, just a brief list of those few that bear the responsibility of a matching release. Frankly, given the brevity of the list, the simplicity of the rules, and the ease of creating compliant accesser methods (there are even tools to automate it, like Accessorizer), I'm mystified as to why *anyone* would have trouble with this. It's just not that hard! The word "create" has nothing more than the ordinary, everyday English meaning in Cocoa. All these docs are saying is, if you create an object by any other means than the listed methods, you're not responsible for releasing it. They're not trying to imply anything about the meaning of the word "create," or whether this method or that fits the definition of the word, etc. When programming in Cocoa, I've found that common sense goes much farther than nit-picking and hair-splitting. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net From gerti at bitart.com Sat May 10 11:34:27 2008 From: gerti at bitart.com (Gerd Knops) Date: Sat May 10 11:34:31 2008 Subject: NSLog every selector on an object? In-Reply-To: References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> Message-ID: <9A59693A-37CF-4A1C-AD10-3DE870304223@bitart.com> On May 9, 2008, at 9:44 PM, Matt James wrote: > Is there any way to overload a class in such a manner as to print > out every > method call it makes at any given time before it runs the method? > Right > now, I'm overloading a few methods of this particular class and > putting > NSLog's at the first line, but I was wondering if there was a way to > jump in > before _ALL_ methods on an object and perform this particular task. > Thanks for any help! Aspect-oriented programming allows you to do that, but AFAIK there is no currently supported implementation for Objective-C. See here: http://www.cocoadev.com/index.pl?AspectCocoa Gerd From clarkcox3 at gmail.com Sat May 10 11:36:07 2008 From: clarkcox3 at gmail.com (Clark Cox) Date: Sat May 10 11:36:11 2008 Subject: Understanding reference count ownership In-Reply-To: <76CCAC75-5467-44F3-8356-2812CB31E6C0@gmail.com> References: <20080507213252.GA6101@anthropohedron.net> <68aed4c30805080616j30231422va00a66be8d68f472@mail.gmail.com> <1BA5B4F4-7676-4BD9-925C-0D48ACF8D848@mmalc.com> <20C1FAF0-D999-4DC0-AEDA-C330FE1FCF2D@gmail.com> <21E918F3-8C9C-4DFF-978D-F218932076C0@gmail.com> <76CCAC75-5467-44F3-8356-2812CB31E6C0@gmail.com> Message-ID: On Sat, May 10, 2008 at 8:20 AM, Christiaan Hofman wrote: > > On 8 May 2008, at 7:16 PM, Sherm Pendley wrote: > >> On Thu, May 8, 2008 at 12:48 PM, Christiaan Hofman >> wrote: >> >> On 8 May 2008, at 6:28 PM, Sherm Pendley wrote: >> >>> On Thu, May 8, 2008 at 12:09 PM, Christiaan Hofman >>> wrote: >>> >>> On 8 May 2008, at 5:50 PM, Sherm Pendley wrote: >>>> >>>> On Thu, May 8, 2008 at 11:16 AM, Christiaan Hofman >>>> wrote: >>>> >>>> E.g. initWithObjects:copyItems:. I couldn't find it in the ownership >>>> management docs, nor in the description of the method itself. >>>> >>>> There's no special mention in the method docs, because none is needed - >>>> the general rules apply to this method as-is. >>> >>> The sentence I linked to and mmalc quoted clearly says 'contains "copy"', >>> and this method name obviously contains the word "copy". >>> >>> The linked-to sentence says "if you create it using a method whose name >>> begins with "alloc" or "new" or contains "copy"". You created the array >>> object with +alloc, and then sent it an -initWithObjects:copyItems. >> >> That depends on what "create" means. >> >> Spare me. This isn't politics, and you aren't Bill Clinton. You know >> perfectly well what create means, and you know perfectly well that sending a >> message to an existing object does not create the object. > > Apologies, but I have to respond to this. > > Seriously, I am not Bill Clinton, and I do *not* know what "create" means in > this sentence. It is the simple, English, meaning of the word "create". Nothing more, nothing less: create |kri?e?t| verb [ trans. ] bring (something) into existence > And I know perfectly well that sending a message to an > existing object *can* create an object: -copy generally does, and I happen > to know that this particular initializer *does* create a new object to > replace the receiver (which is a temporary object). But those are > implementation details, and implementation details should not matter. > Personally, I'd say that +array creates a new object. Full stop; +[NSArray array] creates an object. It brings an array into existence. > However the docs say it doesn't. It says no such thing, it only says that, since "array" does not start with "new" or "alloc", nor does it contain the word copy, you are nor responsible for releasing it. >> Anyway, this discussion is turning too philosophical, it's better to >> terminate, because we all know exactly what is meant. >> >> Precisely my point. Newbies tend to get philosophical, debate about the >> precise meaning of the word "create," whether a -retain in some other code >> must be balanced by their own code, etc. > > Exactly, that's why the word "create" should not be in this sentence of the > docs or at least it's meaning should not be decisive about ownership. It's meaning has zero to do with ownership. >> It's all this exploring of hypothetical edge cases and exceptions that >> complicate things; the rules themselves are quite simple and very >> consistent. >> >> sherm-- > > I disagree. It's exploring the edge cases that clarifies the meaning of > things and exposes shortcomings in formulation. You agree reading between > the lines, and I'm saying that the docs should be clear about such a > fundamental point, without the need to read between the lines or using > English grammar rules. The docs are written in English, the reliance on English grammar rules is implicit. > I could give you many examples where the rules in the doc would give me the > wrong answer. But I'll leave that for my bug report. Please file such a report. -- Clark S. Cox III clarkcox3@gmail.com From slittle at free.fr Sat May 10 14:34:12 2008 From: slittle at free.fr (Scott Little) Date: Sat May 10 14:34:27 2008 Subject: NSLog every selector on an object? In-Reply-To: <9A59693A-37CF-4A1C-AD10-3DE870304223@bitart.com> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> <9A59693A-37CF-4A1C-AD10-3DE870304223@bitart.com> Message-ID: <2A94F8AC-56EA-4FAD-A990-F7CFC7F3E22C@free.fr> Hello all, > > On 10/05/2008, at 20:34, Gerd Knops wrote: >> >> >> Aspect-oriented programming allows you to do that, but AFAIK there >> is no currently supported implementation for Objective-C. See here: >> >> http://www.cocoadev.com/index.pl?AspectCocoa >> >> Gerd >> Does anyone know what happened to this? I am very interested in doing something like this, but the source mentioned on CocoaDev is no longer available and my Google-Fu is only returning the same CocoaDev hits and a PDF and a couple of Japanese sites, which do mention a thesis with was never published. Thanks, scott -- It is when I struggle to be brief that I become obscure. - Quintus Horatius Flaccus (Horace) -- Scott Little slittle@free.fr -- sadly no music right now: iTunes is Paused From stephane at sente.ch Sun May 11 02:53:17 2008 From: stephane at sente.ch (=?ISO-8859-1?Q?St=E9phane_Corth=E9sy?=) Date: Sun May 11 03:53:29 2008 Subject: NSLog every selector on an object? In-Reply-To: <2A94F8AC-56EA-4FAD-A990-F7CFC7F3E22C@free.fr> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> <9A59693A-37CF-4A1C-AD10-3DE870304223@bitart.com> <2A94F8AC-56EA-4FAD-A990-F7CFC7F3E22C@free.fr> Message-ID: <7AE72160-8EB1-4FEC-A670-783CD4F2B3C7@sente.ch> I was lucky to get a copy of the source code from its author, Jacob Burkhardt. I put (temporarily) a copy of it on our server: http://www.sente.ch/pub/software/ThirdParty/AspectCocoa-src.zip St?phane On 10 May 2008, at 23:34 , Scott Little wrote: > Hello all, > >> >> On 10/05/2008, at 20:34, Gerd Knops wrote: >>> >>> >>> Aspect-oriented programming allows you to do that, but AFAIK there >>> is no currently supported implementation for Objective-C. See here: >>> >>> http://www.cocoadev.com/index.pl?AspectCocoa >>> >>> Gerd >>> > > Does anyone know what happened to this? I am very interested in > doing something like this, but the source mentioned on CocoaDev is > no longer available and my Google-Fu is only returning the same > CocoaDev hits and a PDF and a couple of Japanese sites, which do > mention a thesis with was never published. > > Thanks, > scott > > -- > It is when I struggle to be brief that I become obscure. > - Quintus Horatius Flaccus (Horace) > -- > Scott Little > slittle@free.fr > -- > sadly no music right now: iTunes is Paused > > > > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev From eckert.julius at googlemail.com Sun May 11 05:03:05 2008 From: eckert.julius at googlemail.com (Julius Eckert) Date: Sun May 11 05:03:09 2008 Subject: Problem with CIFilters Message-ID: <54533ca90805110503o68ab3be1if93d3eedb2737678@mail.gmail.com> Hi, I am implementing something like a coverflow. So I have many visual elements in the background and one which is closer to the user and in focus. I put a transparent layer on top of the background elements, which makes them darker. This is very good to make the user focus more on the element in the foreground. I had applied additionally an backgroundFilter to this transparent layer (CIGaussianBlur. CIBoxBlur ... tried both). This effect is so great I really want it in my product. The problem is that some weird lines appear when other layers are drawn in my scene. Did a short screencast to make this more clear: http://www.mygnu.com/julius/temp/SFBug.mov Has anyone an idea , why this is happening and how I can fix it? BTW: its a quicksilver interface called "silverflow", already available as beta on my website www.jeckert.net.tc , freeware Thanks in advance, Julius From mattejames at gmail.com Sun May 11 06:33:58 2008 From: mattejames at gmail.com (Matt James) Date: Sun May 11 06:34:02 2008 Subject: NSLog every selector on an object? In-Reply-To: <7AE72160-8EB1-4FEC-A670-783CD4F2B3C7@sente.ch> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> <9A59693A-37CF-4A1C-AD10-3DE870304223@bitart.com> <2A94F8AC-56EA-4FAD-A990-F7CFC7F3E22C@free.fr> <7AE72160-8EB1-4FEC-A670-783CD4F2B3C7@sente.ch> Message-ID: <27cd4a440805110633y292bbf42pf92c8d61d9aa2a9c@mail.gmail.com> Thanks for your help everyone! This will definitely keep me busy. :) -Matt From chad+macosx at objectwerks.com Sun May 11 16:45:12 2008 From: chad+macosx at objectwerks.com (objectwerks inc) Date: Sun May 11 16:45:19 2008 Subject: NSLog every selector on an object? In-Reply-To: <27cd4a440805110633y292bbf42pf92c8d61d9aa2a9c@mail.gmail.com> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> <9A59693A-37CF-4A1C-AD10-3DE870304223@bitart.com> <2A94F8AC-56EA-4FAD-A990-F7CFC7F3E22C@free.fr> <7AE72160-8EB1-4FEC-A670-783CD4F2B3C7@sente.ch> <27cd4a440805110633y292bbf42pf92c8d61d9aa2a9c@mail.gmail.com> Message-ID: Listen to bbum (Bill B.) Don't listen to me. Been a long time since I was futzing around in the run time and Bill is in charge of it I believe (or was, at least ObjC 2.0) Chad On May 11, 2008, at 7:33 AM, Matt James wrote: > Thanks for your help everyone! This will definitely keep me busy. :) > -Matt > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev From slittle at free.fr Mon May 12 04:02:00 2008 From: slittle at free.fr (Scott Little) Date: Mon May 12 04:02:10 2008 Subject: NSLog every selector on an object? In-Reply-To: <7AE72160-8EB1-4FEC-A670-783CD4F2B3C7@sente.ch> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> <9A59693A-37CF-4A1C-AD10-3DE870304223@bitart.com> <2A94F8AC-56EA-4FAD-A990-F7CFC7F3E22C@free.fr> <7AE72160-8EB1-4FEC-A670-783CD4F2B3C7@sente.ch> Message-ID: St?phane, G?niale, merci beaucoup! scott -- With or without [religion] you'd have good people doing good things and evil people doing evil things. But for good people to do evil things, it takes religion. - Steven Wienberg -- Scott Little slittle@free.fr -- sadly no music right now: iTunes is Paused On 11/05/2008, at 11:53, St?phane Corth?sy wrote: > I was lucky to get a copy of the source code from its author, Jacob > Burkhardt. I put (temporarily) a copy of it on our server: > > http://www.sente.ch/pub/software/ThirdParty/AspectCocoa-src.zip > > St?phane > > > On 10 May 2008, at 23:34 , Scott Little wrote: > >> Hello all, >> >>> >>> On 10/05/2008, at 20:34, Gerd Knops wrote: >>>> >>>> >>>> Aspect-oriented programming allows you to do that, but AFAIK >>>> there is no currently supported implementation for Objective-C. >>>> See here: >>>> >>>> http://www.cocoadev.com/index.pl?AspectCocoa >>>> >>>> Gerd >>>> >> >> Does anyone know what happened to this? I am very interested in >> doing something like this, but the source mentioned on CocoaDev is >> no longer available and my Google-Fu is only returning the same >> CocoaDev hits and a PDF and a couple of Japanese sites, which do >> mention a thesis with was never published. >> >> Thanks, >> scott >> >> -- >> It is when I struggle to be brief that I become obscure. >> - Quintus Horatius Flaccus (Horace) >> -- >> Scott Little >> slittle@free.fr >> -- >> sadly no music right now: iTunes is Paused >> >> >> >> _______________________________________________ >> MacOSX-dev mailing list >> MacOSX-dev@omnigroup.com >> http://www.omnigroup.com/mailman/listinfo/macosx-dev > > From csalinas at mac.com Mon May 12 09:08:16 2008 From: csalinas at mac.com (Carlos Salinas) Date: Mon May 12 09:08:29 2008 Subject: NSLog every selector on an object? In-Reply-To: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> References: <27cd4a440805092044j4dadcc75x2d0da19247fe90b3@mail.gmail.com> Message-ID: I have an NSProxy subclass that logs the methods sent to a target object. I use the class to test my code. I log the methods into an array. I then compare that array of strings with an expected array of strings. This is useful for verifying that messages between layers and delegates are occuring and in the right order. Call -setExcludedMethods: to specify the methods that are not to be logged. Here's a usage example: // Replace the view with a TestProxy that logs the methods sent to the view. id documentView = [scrollView documentView]; id documentViewProxy = [[TestProxy alloc] initWithTarget:documentView]; // Set the methods that are not logged. NSSet *excludedMethods = [NSSet setWithObjects: @"hitTest:", // Too many of these. Ignore. @"toolTip", @"inLiveResize", nil ]; [documentViewProxy setExcludedMethods:excludedMethods]; 'Los csalinas@mac.com On May 9, 2008, at 8:44 PM, Matt James wrote: > Is there any way to overload a class in such a manner as to print > out every > method call it makes at any given time before it runs the method? > Right > now, I'm overloading a few methods of this particular class and > putting > NSLog's at the first line, but I was wondering if there was a way to > jump in > before _ALL_ methods on an object and perform this particular task. > Thanks for any help! > > -Matt > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev From mikevann at gmail.com Mon May 12 18:48:25 2008 From: mikevann at gmail.com (Michael Vannorsdel) Date: Mon May 12 18:48:33 2008 Subject: ImageLoaderMachO::resolveUndefined Message-ID: <5F253AD4-56F4-4D51-B446-08AFCBEA9DE6@gmail.com> I'm getting a crash in ImageLoaderMachO::resolveUndefined when using CFAllocatorCreate (resolveUndefined is called by __CFAllocatorCreate) to create a custom allocator. The context and the callbacks are all properly set and working. The crash only happens on PPC Tiger; Leopard and all Intel work fine. Anyone know what resolveUndefined does and perhaps why it would be called? From edenwaith at mac.com Tue May 13 20:43:32 2008 From: edenwaith at mac.com (Chad Armstrong) Date: Tue May 13 20:43:40 2008 Subject: NSOpenPanel and Preference window crash In-Reply-To: <20080508151600.C128B17E5A6@forums.omnigroup.com> References: <20080508151600.C128B17E5A6@forums.omnigroup.com> Message-ID: Hello: I'm encountering an odd crash. If I open up my Preference window in my application, and then go to File > Open (or press Command-O), this causes the program to either hang or crash. It seems that it keeps getting stuck when it is trying to open the NSOpenPanel (int result = [open_panel runModal];). However, if the Preference window is closed, I can open up a file, no problem. It is when a file hasn't been opened yet, and if I open up the Preference window and then try and open a file, it locks up the program. Any ideas on what might be going wrong? Here's an example of the crash log. Date/Time: 2008-05-02 19:06:09.302 -0500 OS Version: Mac OS X 10.5.2 (9C7010) Report Version: 6 Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x000000000000000b Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x93a8d5cb _cache_flush + 85 1 libobjc.A.dylib 0x93a974c1 flush_marked_caches + 84 2 libobjc.A.dylib 0x93a9a497 _read_images + 996 3 libobjc.A.dylib 0x93a9043d map_images + 6242 4 dyld 0x8fe04af8 dyld::notifyBatchPartial(dyld_image_states, bool, char const* (*) (dyld_image_states, unsigned int, dyld_image_info const*)) + 744 5 dyld 0x8fe1057b ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, ImageLoader::RPathChain const&) + 251 6 dyld 0x8fe051ae dyld::link(ImageLoader*, bool, ImageLoader::RPathChain const&) + 158 7 dyld 0x8fe0bb73 dlopen + 691 8 libSystem.B.dylib 0x929cda22 dlopen + 66 9 com.apple.Foundation 0x901be69c _NSSoftLinkingLoadFramework + 236 10 com.apple.AppKit 0x951bac16 -[NSNavView _iLifeMediaBrowserFrameworkInstalled] + 92 11 com.apple.AppKit 0x951bab77 -[NSNavView shouldShowMediaBrowser] + 61 12 com.apple.AppKit 0x951ba981 -[NSNavView _loadMediaBrowserNodeIfRequired] + 36 13 com.apple.AppKit 0x951ba8d0 -[NSNavView configureAndLoadLayout] + 48 14 com.apple.AppKit 0x951ba888 - [NSSavePanel(NSSavePanelRuntime) _loadPreviousModeAndLayout] + 45 15 com.apple.AppKit 0x951ba680 - [NSSavePanel(NSSavePanelRuntime) runModalForDirectory:file:types:] + 77 16 com.mycompany.myApp 0x00002ff0 -[MyController getFile:] + 525 (MyController.m:580) 17 com.apple.AppKit 0x95063e56 -[NSApplication sendAction:to:from:] + 112 18 com.apple.AppKit 0x951127cc -[NSMenu performActionForItemAtIndex:] + 493 19 com.apple.AppKit 0x951124d1 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 220 20 com.apple.AppKit 0x950ef3ae AppKitMenuEventHandler + 6608 21 com.apple.HIToolbox 0x92e0dfc3 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1181 22 com.apple.HIToolbox 0x92e0d3fd SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 405 23 com.apple.HIToolbox 0x92e29e0e SendEventToEventTarget + 52 24 com.apple.HIToolbox 0x92e5e86d SendHICommandEvent(unsigned long, HICommand const*, unsigned long, unsigned long, unsigned char, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 411 25 com.apple.HIToolbox 0x92e84fbf SendMenuCommandWithContextAndModifiers + 59 26 com.apple.HIToolbox 0x92e84f7c SendMenuItemSelectedEvent + 134 27 com.apple.HIToolbox 0x92e84e7e FinishMenuSelection(MenuData*, MenuData*, MenuResult*, MenuResult*, unsigned long, unsigned long, unsigned long, unsigned char) + 162 28 com.apple.HIToolbox 0x92e61b1e MenuSelectCore(MenuData*, Point, double, unsigned long, OpaqueMenuRef**, unsigned short*) + 640 29 com.apple.HIToolbox 0x92e61509 _HandleMenuSelection2 + 383 30 com.apple.HIToolbox 0x92e6137d _HandleMenuSelection + 53 31 com.apple.AppKit 0x9502bf77 _NSHandleCarbonMenuEvent + 244 32 com.apple.AppKit 0x94f92c72 _DPSNextEvent + 1834 33 com.apple.AppKit 0x94f9208e -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128 34 com.apple.AppKit 0x94f8b0c5 -[NSApplication run] + 795 35 com.apple.AppKit 0x94f5830a NSApplicationMain + 574 36 com.mycompany.myApp 0x00001e7e _start + 216 37 com.mycompany.myApp 0x00001da5 start + 41 Regards, Chad From trent at jacobs.co.za Thu May 15 14:10:29 2008 From: trent at jacobs.co.za (Trent Jacobs) Date: Thu May 15 14:10:34 2008 Subject: Forcing a refresh on a bound control Message-ID: Hi all, In my core data app I have an entity which I chose to derive from a NSManagedObject class because I wanted to do some formatting and data manipulation on one of the attributes which I have bound to a NSTextView. The formatting is conditional based on a chechbox on the UI (in the preferences panel). What I need to do is get the NSTextView to know to reload the attribute from my managed object when the checkbox changes. in other words, it must know to refresh the data in Attribute X even though the data in Attribute X hasn't changed. I've searched for some attribute of the NSTextView which I can bind to the user defaults (the checkbox updates the user defaults) but no luck. I can't find any examples anywhere to help me out either. Can anyone point me to some documentation I may have missed? Thanks! From cmhofman at gmail.com Thu May 15 14:35:58 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Thu May 15 14:43:18 2008 Subject: Forcing a refresh on a bound control In-Reply-To: References: Message-ID: <20166d560805151435l663ef905ped9cc6ce290ec9a5@mail.gmail.com> You can force a KVO notification by sending a will/didChangeValueForKey: pair of messages. Christiaan On Thu, May 15, 2008 at 11:10 PM, Trent Jacobs wrote: > Hi all, > > In my core data app I have an entity which I chose to derive from a > NSManagedObject class because I wanted to do some formatting and data > manipulation on one of the attributes which I have bound to a NSTextView. > The formatting is conditional based on a chechbox on the UI (in the > preferences panel). > > What I need to do is get the NSTextView to know to reload the attribute > from my managed object when the checkbox changes. in other words, it must > know to refresh the data in Attribute X even though the data in Attribute X > hasn't changed. > > I've searched for some attribute of the NSTextView which I can bind to the > user defaults (the checkbox updates the user defaults) but no luck. I can't > find any examples anywhere to help me out either. > > Can anyone point me to some documentation I may have missed? > > Thanks! > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev > From achille.talon at gmail.com Fri May 16 06:32:33 2008 From: achille.talon at gmail.com (Coockie_jr) Date: Fri May 16 06:32:36 2008 Subject: [c++]Retrieving system information Message-ID: <17262844.post@talk.nabble.com> I'm working with c++ language and I'm trying to collect as much a information as possible on a MAC OS system like , nb of cpu, frequency usage of cpu memory usage of mem list of process and their cpu usage ... I searched a bit and it seems that sysctl may be the best to collect most of the needed information but I get odd results for some request like hw.cpufrequency although i get the correct output while using the terminal command. exemple of request int frequency; len = sizeof(frequency); if (sysctlbyname("hw.cpufrequency", &frequency, &len, NULL, 0) == -1){ std::cout << "error"; } else{ std::cout << "frequency of processor " << frequency << std::endl; } This gives me an error while searching for hw.busfrequency works well. Am i looking at the right tools for this kind of job ? -- View this message in context: http://www.nabble.com/-c%2B%2B-Retrieving-system-information-tp17262844p17262844.html Sent from the OmniGroup - MacOSX-Dev mailing list archive at Nabble.com. From mah at jump-ing.de Fri May 16 07:01:17 2008 From: mah at jump-ing.de (Markus Hitter) Date: Fri May 16 07:01:24 2008 Subject: [c++]Retrieving system information In-Reply-To: <17262844.post@talk.nabble.com> References: <17262844.post@talk.nabble.com> Message-ID: Am 16.05.2008 um 15:32 schrieb Coockie_jr: > Am i looking at the right tools for this kind of job ? System Profiler has a command line interface: man system_profiler Markus - - - - - - - - - - - - - - - - - - - Dipl. Ing. Markus Hitter http://www.jump-ing.de/ From achille.talon at gmail.com Fri May 16 07:59:10 2008 From: achille.talon at gmail.com (Coockie_jr) Date: Fri May 16 07:59:12 2008 Subject: [c++]Retrieving system information In-Reply-To: References: <17262844.post@talk.nabble.com> Message-ID: <17276803.post@talk.nabble.com> System_profiler seems to give most of the "statics" information I need but it doesn't give any dynamic information like cpu usage etc.. I guess I'll have to sick to sysctl. Markus Hitter wrote: > > > Am 16.05.2008 um 15:32 schrieb Coockie_jr: >> Am i looking at the right tools for this kind of job ? > > System Profiler has a command line interface: man system_profiler > > > Markus > > - - - - - - - - - - - - - - - - - - - > Dipl. Ing. Markus Hitter > http://www.jump-ing.de/ > > > > > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev > > -- View this message in context: http://www.nabble.com/-c%2B%2B-Retrieving-system-information-tp17262844p17276803.html Sent from the OmniGroup - MacOSX-Dev mailing list archive at Nabble.com. From cmhofman at gmail.com Fri May 16 12:12:27 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Fri May 16 12:12:35 2008 Subject: QuickLook with default app for file Message-ID: <15600365-022A-4754-A8F5-A2193D160A20@gmail.com> Hi List, I have a question about problems with QuickLook support for files that have a default app to open set. My app can open PDFs. When it is set as the default app to open a PDF file, QuickLook for this file shows the icon intead of the thumbnail. To be clear, my app does *not* provide a QuickLook plugin for PDFs. Why would the system plugin not work in this case? Thanks, Christiaan From jjalon at gmail.com Fri May 16 13:39:23 2008 From: jjalon at gmail.com (Julien Jalon) Date: Fri May 16 13:39:26 2008 Subject: QuickLook with default app for file In-Reply-To: <15600365-022A-4754-A8F5-A2193D160A20@gmail.com> References: <15600365-022A-4754-A8F5-A2193D160A20@gmail.com> Message-ID: This should not happen. What happens if you try in a terminal: qlmanage -t /path/to/one/of/your/file.pdf What UTI does it show? What plug-in does it use? Maybe your application redefines the PDF type and change its UTI to something else (i.e. not "com.adobe.pdf") As PDF is a built-in OS type, you should not redeclare it in your application and only use "com.adobe.pdf" to reference PDF files in your application (so no reference to file extensions or other kind of type tags). At this point, PDF files can't participate any more to the system wide plug-ins relying on proper typing. -- Julien On Fri, May 16, 2008 at 9:12 PM, Christiaan Hofman wrote: > Hi List, > > I have a question about problems with QuickLook support for files that have > a default app to open set. My app can open PDFs. When it is set as the > default app to open a PDF file, QuickLook for this file shows the icon > intead of the thumbnail. To be clear, my app does *not* provide a QuickLook > plugin for PDFs. Why would the system plugin not work in this case? > > Thanks, > Christiaan > > _______________________________________________ > MacOSX-dev mailing list > MacOSX-dev@omnigroup.com > http://www.omnigroup.com/mailman/listinfo/macosx-dev > From cmhofman at gmail.com Sat May 17 06:59:08 2008 From: cmhofman at gmail.com (Christiaan Hofman) Date: Sat May 17 06:59:17 2008 Subject: Using static NSString as observation context Message-ID: <0D314217-EB93-4F8E-A493-74C5183CD6CB@gmail.com> I have recently changed some KVO observation code to us a static NSString as the context when registering as KVO observation. However now that seems to have introduced a crasher when removing the observer, at least on a Core Duo Intel machine. PPC does not seem to have any problem. So is there some problem using NSStrings as observation context for Intel? The Sketch sample code also uses those. Christiaan From georg.seifert at gmx.de Sat May 17 08:16:47 2008 From: georg.seifert at gmx.de (Georg Seifert) Date: Sat May 17 08:16:55 2008 Subject: python scripting support Message-ID: Hello, I want wo be able to make my program scriptable. Most important with python. My program is written in ObjectC in XCode 3 I have read lots of stuff in the net. What is the better possibility: 1) make it scriptable with AppleScript and use the Python/Applescript bridge or 2) embed it (with the python framework) and use "Py_Initialize();" and "static PyMethodDef EmbMethods[] = {" to 1: - it is possible to use more than on scripting languages (appleScript, python, javascript) - it integrates in the system to 2: - I have to wrap up my classes (I didn?t found any example doing this with ObjectC classes, only C++) - I can have a tighter integration in my program - the program can?t be remote controlled (as with apple script) Does anyone has some pros/cons for both approaches? Does anyone have examples/explanation for the second approach. The applescript support seems to be quite well documented. Thanks in advance Georg From hengist.podd at virgin.net Sat May 17 14:12:59 2008 From: hengist.podd at virgin.net (has) Date: Sat May 17 14:13:08 2008 Subject: python scripting support In-Reply-To: <20080517185947.EBB36194AD0@forums.omnigroup.com> References: <20080517185947.EBB36194AD0@forums.omnigroup.com> Message-ID: <24363AEF-8421-483F-B15D-71AB5EE5566E@virgin.net> Georg Seifert wrote: > I want wo be able to make my program scriptable. Most important with > python. > > My program is written in ObjectC in XCode 3 > > I have read lots of stuff in the net. > What is the better possibility: > > 1) make it scriptable with AppleScript and use the Python/Applescript > bridge or > 2) embed it (with the python framework) and use "Py_Initialize();" and > "static PyMethodDef EmbMethods[] = {" > > to 1: > - it is possible to use more than on scripting languages (appleScript, > python, javascript) The following languages are practical options for controlling applications via Apple events: AppleScript, Perl (via Mac::Glue) and Python, Ruby, and ObjC (via appscript or Scripting Bridge). (JavaScriptOSA is academic since nobody uses it.) OTOH, if your application needs to call functions in scripts, the only languages available as full OSA components are AppleScript and JavaScriptOSA. There's also PyOSA which is mostly functional, but it's a developer release and I wouldn't recommend it for production use. > - it integrates in the system > > to 2: > - I have to wrap up my classes (I didn?t found any example doing this > with ObjectC classes, only C++) Piece of cake with PyObjC. See , and ask on the PythonMac-SIG mailing list for further advice . > - I can have a tighter integration in my program OSA gives reasonable integration, though the coupling is still looser (good for flexibility, at least in theory; not so good for efficiency since all data is passed by copy). > - the program can?t be remote controlled (as with apple script) Embedding an interpreter doesn't prevent you adding an Apple event API at a later date. And don't forget there are other IPC options you could use, e.g. Distributed Objects. Maybe not as popular for desktop integration, but still quite usable (e.g. DO can be used fro ObjC or any language with an ObjC bridge - Perl, Python, Ruby, etc). > Does anyone has some pros/cons for both approaches? In addition to the above: Apple event IPC is a well established standard (pro), but a bit fiddly to implement well (con). An embedded interpreter will be simple to add (pro for you), but your users may or not appreciate being required to use one particular language (possible con). If you want a specific recommendation, provide more information about the nature of the application and what scripters will do with it. HTH has -- Control AppleScriptable applications from Python, Ruby and ObjC: http://appscript.sourceforge.net From hsoi at hsoi.com Sat May 17 14:47:13 2008 From: hsoi at hsoi.com (John C. Daub) Date: Sat May 17 14:53:59 2008 Subject: python scripting support In-Reply-To: Message-ID: on 5/17/08 10:16 AM, Georg Seifert at georg.seifert@gmx.de wrote: > I want wo be able to make my program scriptable. Most important with > python. Why is Python most important? Because you like it and know it well? or because it's what the vast majority of your users use? The point is, make sure you choose a solution that suits your users best. > 1) make it scriptable with AppleScript and use the Python/Applescript > bridge or > 2) embed it (with the python framework) and use "Py_Initialize();" and > "static PyMethodDef EmbMethods[] = {" Either way can work, just depends what you want. Some technical limitations tho: 1. Scripting bridge is only available (as an OS built-in) in Mac OS X 10.5 and later. If your need to support prior OS versions, you may need to do some additional work with PyObjC to get things available with Python. I'm not sure what that would entail exactly, just pointing out that Scripting Bridge is 10.5 and later. 2. If you are going to embed Python in your app, you're going to risk issues with the system. For instance, in one of the apps I write I embed Python. We built it back when Tiger was the OS and so we built against Python 2.3.5, since that's what was in the 10.4 OS SDK. We are able to have our app run on Leopard because while Apple did update the built-in Python.framework to use Python 2.5.1, they did ship a minimal runtime of 2.3. Now if in Mac OS X 10.6 Apple doesn't ship a Python 2.3, my app may break. Apple's suggestion is basically to make your own Python.framework, embed it within your app, and use that. IMHO that's not ideal, but what else can you do? I'm actually working on making another one of my apps scriptable via AppleScript right now. And if you happen to be writing a Cocoa-based app, the Cocoa Scripting support is pretty nice for adding scripting support into your app. I think the advantage of the AppleScript route is that AppleScript is kinda the native scripting language of the OS. If your app is AppleScriptable, a whole world is open to you and your users, and they can have a great deal of flexibility... if nothing else, they could write their scripts in AppleScript or Python, useful if they know one language but not the other and saves them from having to learn a language just to write scripts to drive your app. If you write in Python, it just doesn't open up as many doors as AppleScript does. While I personally like the Python language a lot and find writing AppleScripts to often be a masochistic exercise, the technology of AppleScript and how it plays into the greater OS and user experience -- I think -- makes it the way to go in terms of your app's scripting language. I think it gives the most options and flexibility, and hopefully few limits and/or problems. Just my opinion. -- John C. Daub }:-)>= "Weak mind, weak fist. Strong mind, no need for fist." From rob at menumachine.com Sat May 17 19:44:19 2008 From: rob at menumachine.com (Rob Keniger) Date: Sat May 17 19:44:24 2008 Subject: Using static NSString as observation context In-Reply-To: <0D314217-EB93-4F8E-A493-74C5183CD6CB@gmail.com> References: <0D314217-EB93-4F8E-A493-74C5183CD6CB@gmail.com> Message-ID: <8BD70F93-49B5-48C1-8822-11727F452658@menumachine.com> On 17/05/2008, at 11:59 PM, Christiaan Hofman wrote: > I have recently changed some KVO observation code to us a static > NSString as the context when registering as KVO observation. However > now that seems to have introduced a crasher when removing the > observer, at least on a Core Duo Intel machine. PPC does not seem to > have any problem. So is there some problem using NSStrings as > observation context for Intel? The Sketch sample code also uses those. I've not had a problem, but I cast the string to a void*. I use a definition like this: static void* MyObservationContext=(void*) @"MyObservationContext"; -- Rob Keniger From mmalc-lists at mmalc.com Sat May 17 23:18:00 2008 From: mmalc-lists at mmalc.com (mmalc Crawford) Date: Sat May 17 23:18:04 2008 Subject: Forcing a refresh on a bound control In-Reply-To: <20166d560805151435l663ef905ped9cc6ce290ec9a5@mail.gmail.com> References: <20166d560805151435l663ef905ped9cc6ce290ec9a5@mail.gmail.com> Message-ID: <75567B87-AEC5-421D-A541-6708038B1547@mmalc.com> On May 15, 2008, at 2:35 PM, Christiaan Hofman wrote: > You can force a KVO notification by sending a will/ > didChangeValueForKey: > pair of messages. > As has been said on numerous occasions, no, don't do this. On May 15, 2008, at 2:10 PM, Trent Jacobs wrote: > In my core data app I have an entity which I chose to derive from a > NSManagedObject class because I wanted to do some formatting and > data manipulation on one of the attributes which I have bound to a > NSTextView. The formatting is conditional based on a chechbox on the > UI (in the preferences panel). > It's not clear why the formatting should be part of the behaviour of the managed object class. It would seem more appropriate to move the formatting logic to another object which then either has a reference to the checkbox or observes a value that the checkbox modifies. mmalc From hengist.podd at virgin.net Sun May 18 02:56:42 2008 From: hengist.podd at virgin.net (has) Date: Sun May 18 02:56:49 2008 Subject: python scripting support Message-ID: <7CBE2470-C9C0-487D-BC6F-4147EE9A9F50@virgin.net> John C. Daub wrote: > 1. Scripting bridge is only available (as an OS built-in) in Mac OS > X 10.5 and later. If your need to support prior OS versions, you may > need to do some additional work with PyObjC to get things available > with Python. I'm not sure what that would entail exactly, just > pointing out that Scripting Bridge is 10.5 and later. While I don't have numbers, my impression is that appscript remains pretty much the de-facto standard for scripting applications from Python. It supports 10.3.9 and later, is much better designed and more reliable than SB, and provides a much nicer native API. Better documentation and dev tools too. Requires separate user installation, but that's easy to do. > 2. If you are going to embed Python in your app, you're going to > risk issues with the system. For instance, in one of the apps I > write I embed Python. We built it back when Tiger was the OS and so > we built against Python 2.3.5, since that's what was in the 10.4 OS > SDK. We are able to have our app run on Leopard because while Apple > did update the built-in Python.framework to use Python 2.5.1, they > did ship a minimal runtime of 2.3. IIRC the problem here is that Python 2.3 isn't officially supported on Leopard - it's several years old now and no longer maintained beyond critical security fixes. So it goes. I'd suggest updating your app to use 2.5.x, or even 2.6 if you wait a few more months. > Apple's suggestion is basically to make your own Python.framework, > embed it within your app, and use that. IMHO that's not ideal but > what else can you do? You can get a prebuilt framework build from python.org, and embedding it in your application bundle is trivial. It will add a few MB to your application's file size, but unless you're distributing over dialup that's really a non-issue. Only significant issue is supporting third- party modules (how to install them, where to put them), but the PythonMac-SIG folks will be the best ones to advise on that. > I think the advantage of the AppleScript route is that AppleScript > is kinda the native scripting language of the OS. Only inasmuch as AppleScript currently remains the most popular choice for ap