Re: Releasing Objects
On Wed, Dec 23, 2009 at 12:05 PM, Bill Bumgarner b...@mac.com wrote: On Dec 22, 2009, at 11:49 PM, Franck Zoccolo wrote: You said that you're using garbage collection. When using GC retain and release messages do nothing, and the retain count is not used to determine when an objet can be freed from memory. If -retainCount is returning 1, then he can't be using GC. Under GC, -retainCount -- being the utterly useless method that it is that no one should ever call -- returns self. b.bum Wait, what? I could understand that under GC -retain might be nothing more than the equivalent of - (id)retain { return(self); }, but -retainCount? Is it really - (NSUInteger)retainCount { return((NSUInteger)self); } ? Wouldn't it make more sense to just return 1, or maybe something like NSUIntegerMax? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Is there a warning for this?
All, I had this code: [[fetchedResultsController sections] count] Which always returned zero even thought sglite showed entries in the table. When I put a break point on the getter, nothing happened. Amazingly, it dawned on me pretty quickly that I needed this: [[self.fetchedResultsController sections] count] (notice the 'self' at the start) Is there some way to turn on a warning saying 'you are directly accessing an ivar where a (non-trivial) getter/setter exists'? Thanks.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [textView:shouldChangeTextInRanges:replacementStrings:] When does this type of event occur?
On Dec 23, 2009, at 10:58 PM, Dave DeLong wrote: In many apps, you can hold down the option key to change the cursor into a crosshair, and do a vertical selection. In addition, in apps like Pages, you can hold down the command key to do a non- contiguous selection. I'd imagine that both of these scenarios might result in that method getting invoked. That explains how to get a non-continuous selection but not how you can change the text in multiple locations. Let's say you have a non-continuous selection and you type or paste some text, it just delete the selection and insert the new text in the first selection range (tested in TextEdit). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Releasing Objects
On Dec 24, 2009, at 2:23 AM, John Engelhart wrote: On Wed, Dec 23, 2009 at 12:05 PM, Bill Bumgarner b...@mac.com wrote: On Dec 22, 2009, at 11:49 PM, Franck Zoccolo wrote: You said that you're using garbage collection. When using GC retain and release messages do nothing, and the retain count is not used to determine when an objet can be freed from memory. If -retainCount is returning 1, then he can't be using GC. Under GC, -retainCount -- being the utterly useless method that it is that no one should ever call -- returns self. b.bum Wait, what? I could understand that under GC -retain might be nothing more than the equivalent of - (id)retain { return(self); }, but -retainCount? Is it really - (NSUInteger)retainCount { return((NSUInteger)self); } ? Wouldn't it make more sense to just return 1, or maybe something like NSUIntegerMax? There is no implementation of -retainCount under GC. There's a short-circuit in obj_msgSend that detects the selector for the memory management methods which are no-ops. Since -retain and -autorelease have to return self, that's what the short-circuit does. -retainCount gets the same treatment and so the same return value. The return value doesn't matter, anyway. (Frankly, it hardly matters under managed memory, either.) Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Adding sub menus programatically
Hi, I have googled around but have found nothing that can help me with this... I have a menu in my application that I wish to add sub items to programatically. I have the Menu itself connected up and I can add NSMenuItems to it just fine, but seem at a loss to be able to add a sub menu and the sub itmes to that menu. I suspect my answer lies in this function: - (void)setSubmenu:(NSMenu *)aMenu forItem:(NSMenuItem *)anItem But I do not understand what the forItem part of the method is for. Further, I can retrieve a menu item from the menu, but am also at a loss as to how to retrieve my submenu at a stage in the future. I have a feeling that there is something very simple that I am not understanding here, and would be very grateful if someone could point me in the right direction. And Merry Christmas to everyone!!! Mikey___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Call Cocoa from C++
On 17.12.2009, at 20:24, Randall Meadows wrote: Just like that. Put this into a .mm file, and it'll compile as Objective-C++. You'll get a compiler warning that objcptr may not respond to updateText, which you can eliminate by casting objcptr to the appropriate class. By the way, neat trick: The header objc/objc.h is a C-language header implementing the runtime. It defines some standard types used by Objective-C, including id. So if you include this, your headers can use the id data type even if they're included from plain C++ or C files. I.e. your header and source file would be: // MyClass.h #include objc/objc.h class MyClass { public: id objcptr; // ptr to my obj-c object void CallOBJC(void); } // MyClass.mm MyClass::CallOBJC() { [objcptr updateText]; } You can't ObjC-style qualify the id with a category, as in idMyUpdateTextProtocol, but it's a tad more elegant. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.lookandfeelcast.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSCollectionView NSArrayController bindings from outer hell
On 24 Dec 2009, at 05:53, Nicolas Berloquin wrote: Hi ! I must have killed the gods of array bindings in a previous life, but I'm pulling my hair (or whatever's left), and, even though I thought I got I, well, I really don't. I'm trying to do something quite simple. I'd like to display a series of images with a label inside an NSCollectionView. Whatever I do, the collectionview remains empty (even though I can see the nice checkered background (since I set up default layout rows/cols) which reflects the size of my customized item view). Why not use IKImageBrowserView? It's a perfect match for grids of images with titles. And faster too. In a nib file that has a couple windows, the File's Owner is an NSWindowController of mine. Right now, it concentrates most of the controlling. The NSMutableArray which contains the images and strings is a property of the windowController. I created an NSArrayController, bound to the File's Owner, with the model key path to the name of my array (checked spelling etc). I created an NSCollectionView and set it up like this : - content is bound to the arrayController, and controller key is arrangedObjects. - the item prototype is the NSCollectionViewItem that got created automatically. - for the NSCollectionViewItem, its view is the auto-created view that I customized to add an NSImageView and a label. Now, I tried with and without setting the fields in the Attributes inspector. Since the View is inside the same nib as the NSCollectionViewItem, I think I can leave this blank, since the outlet connects them already. - for the view itself (that should be drawn inside the collectionview), the NSTextField (not the cell) is bound to the Collection View Item, and the model key path is set to representedObject._imageUID. (_ImageUID is a property of the content of my NSMutableArray. To make it short, I add simple class instances that have two fields, NSImageView *_image, NSString *_imageUID) - the NSImageView is bound the same way, but to representedObject._image. From what I read all over the net, this should be one way to do it... So, now on to the model side. Maybe my array isn't observed as being updated. I tried a few things... with and without declaring the NSMutableArray as a property, and assigning it through a setter in windowControllerDidLoadNib. I use insertObject: atIndex: to add elements to the array. And I made sure that I add them from the main thread (performOnMainThread or similar calls when necessary). I traced the content of the NSCollectionView from the debugger, and it seems that it doesn't see any of that. But maybe I shouldn't worry about what I see ? The collectionView shows : _content has 0 objects _displayedItems has 0 objects I tried setting the NSCollectionView's content by hand, (with setContent: myArray) but then I get lots of weird warnings : *Could not connect the action orderFrontStandardAboutPanel: to target of class NSCollectionViewItem* *Could not connect the action hide: to target of class NSCollectionViewItem* Could not connect the action terminate: to target of class NSCollectionViewItem *Could not connect the action hideOtherApplications: to target of class NSCollectionViewItem* *Could not connect the action unhideAllApplications: to target of class NSCollectionViewItem* * * And I also tried to send setNeedsDisplay: YES to the collectionView, just in case... So, if anyone has any suggestion, I'd be really glad to hear them. I really don't understand what goes wrong. Somehow, this technology, It simply doesn't work... :) thanks ! ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is there a warning for this?
Am 24.12.2009 um 09:26 schrieb Brian Bruinewoud: All, I had this code: [[fetchedResultsController sections] count] Which always returned zero even thought sglite showed entries in the table. When I put a break point on the getter, nothing happened. Amazingly, it dawned on me pretty quickly that I needed this: [[self.fetchedResultsController sections] count] (notice the 'self' at the start) Is there some way to turn on a warning saying 'you are directly accessing an ivar where a (non-trivial) getter/setter exists'? Not that I know. But you are free to give your ivars another name like ivarFetchedResultsController. Then you will get an error if you try the first example. atze ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSCollectionView NSArrayController bindings from outer hell
Why not use IKImageBrowserView? It's a perfect match for grids of images with titles. And faster too. Hi ! Well, I started out with IKImageBrowserView and it worked really well, but I needed to be able to save the whole thing as an image, and have real control over what happens with the item views etc, so I switched to NSCollectionViews. The good news is that I figured out what was wrong. I think the culprit was that I didn't completely understand how array binding worked, I was adding objects directly to my array instead of having kvo methods in my document and passing the calls through the document itself. The strange thing is that once I made the changes, it still didn't work. I had to remove then recreate the NSCollectionView and all the views and arraycontroller in IB before it worked right. Or maybe the chickens helped :) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is there a warning for this?
On Dec 24, 2009, at 3:26 AM, Brian Bruinewoud br...@darknova.com wrote: Is there some way to turn on a warning saying 'you are directly accessing an ivar where a (non-trivial) getter/setter exists'? I'm assuming you're targeting iPhone OS. If you can deal with not running your code in the simulator, switching to synthesized ivars where possible might avoid this situation in most cases, since you would either need self. or self- to access the property/ivar. Otherwise, give your ivars a prefix (underscore is verboten according to Apple, since they use it in the frameworks). Oh, and if not being able to use the new runtime (and therefore synthesized ivars) in the simulator bothers you, file a bug. Same with the lack of namespacing leading to rules like thou shalt not prefix identifiers with underscores. If enough of us complain about something, Apple might take our opinions into consideration. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSViewAnimationFadeInEffect broken in Snow Leopard?
On Tue, Dec 22, 2009 at 7:58 PM, Kevin Wojniak kain...@kainjow.com wrote: NSViewAnimationFadeInEffect doesn't seem to be working like it was in Leopard. I filed this as when SL was being seeded. If Regression: NSViewAnimation doesn't fade in view if initially hidden rdar://problem/7020352 If this affects you, you should also file a bug. The workaround is to show the view before running the animation. - Jim ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Adding sub menus programatically
On Dec 24, 2009, at 4:25 AM, Michael Davey wrote: Hi, I have googled around but have found nothing that can help me with this... I have a menu in my application that I wish to add sub items to programatically. I have the Menu itself connected up and I can add NSMenuItems to it just fine, but seem at a loss to be able to add a sub menu and the sub itmes to that menu. I suspect my answer lies in this function: - (void)setSubmenu:(NSMenu *)aMenu forItem:(NSMenuItem *)anItem But I do not understand what the forItem part of the method is for. Further, I can retrieve a menu item from the menu, but am also at a loss as to how to retrieve my submenu at a stage in the future. I have a feeling that there is something very simple that I am not understanding here, and would be very grateful if someone could point me in the right direction. And Merry Christmas to everyone!!! anItem is a pointer to the menu item to which you wish to connect the submenu. I was working on code to do this yesterday, and I saw this method, but I preferred instead to just use the -setSubmenu method of my menu items. What you might not be understanding is that you attach a menu to the submenu property of a menu item. You don't add a submenu to a menu as you seem to have put it above. In either case, in the future, when you want to get the submenu, you can send the -submenu message to your menu item that has the submenu attached to it in order to retrieve the submenu. If you don't know which menu item has a particular submenu that you are interested in, you can search through them, or you could set the tag of the menu item of interest and find the item that has that tag at some later time using NSMenu's –itemWithTag: method. Definitely read the menu programming guide and and NSMenu and NSMenuItem class descriptions and I think you'll find that menus are one of the most straightforward parts of Cocoa to understand.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data Anomaly?
On Dec 23, 2009, at 9:25 PM, Henry McGilton (Boulevardier) wrote: On Dec 23, 2009, at 7:41 PM, Richard Somers wrote: In my application when I do the following something strange happens. Add a managed object to the store, save the file, then save the file as another name. Upon saving the file with another name, core data will create and then destroy some kind of transitory shadow object of the same kind as the one in the store. Is this normal? Just a wild guess --- are you saving atomically? When writing NSData objects, as one example, you can write to file atomically, in which case the object is written to a backup file which is renamed if the write succeeds. The idea is that the write either succeeds or fails, but nothing in between that would leave a corrupted file ... This could be what is happening but I will need to check into it more. I started with a standard core data project template so I do not know if I am saving atomically or not. Some of my managed objects are NSData. The resulting file is not corrupted. I use -didTurnIntoFault to cleanup caches for the managed objects. The cache is not created until the managed object is used for the first time. In -didTurnIntoFault I did not check to see if the cache existed, I just assumed that if the managed object existed it would be used and the cache would exist. Bad assumption. So I was attempting to remove a non-existing cache on this this transitory shadow object that was never used by my application. --Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableview datasource issues
... The issue is that reloadData was not launching datasource methods, regardless. ... My concern though: how come Xcode does not flag issues with datasource? What is so strange is that [segmentTableView editColumn:k row:i withEvent:nil select:YES] was launching the datasource methods, whereas reloadData was not. What would Xcode do, debug the code by itself? If reloadData was the actual cause of the bug, then why isn't this problem reported more often? Surely, you're not the only one using reloadData. There was obviously some kind of bug in the code or in its connections to other things. Finding out exactly what that bug is would require the full source project of the malfunctioning program. If you haven't saved that, then the information is lost forever. If you have saved it, then send it in a bug report to Apple. You can also post the zipped project somewhere like pastebin.com and post the URL to the list. Anyone who's interested can then attack the problem. Every programmer eventually creates code that they themselves can't debug. Sometimes the bug isn't found despite considerable effort, and a rewrite ensues. Sometimes another programmer finds the bug, but I've never seen that happen without the source. Occasionally the bug is eventually found by its creator, and with luck, it's accompanied by a profound feeling of revelation, even epiphany. One doesn't always have the time, though, so sometimes one must rewrite and move on. -- GG ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[iPhone] NSKeyedArchiver with NSValue Objects
I bashed into a problem with NSKeyedArchiver trying to encode NSValue objects. I am using NSValue to wrap up CGPoint and CGSize structures, then doing an encodeObject: forKey: to encode the NSValue. I get this message: [NSKeyedArchiver encodeValueOfObjCType:at:]: this archiver cannot encode structs' I poked around in CocoaBuilder and Google for some definitive answers, but the discussions appear to be mostly froth. This seems a little strange, as UIKit provides a bunch of NSValue additions to encode those CG structs, but the NSKeyedArchiver can't encode them. And the message is somewhat misleading: I'm encoding the NSValue object, not the structure . . .I'm assuming (I know, one should never assume) that the NSValue object is invoking that encodeValueOfObjCType:at: message . . . I'd like to get some clarification or definitive answers on what's going on . . . The available discussions I was able to find were not very helpful . . . In the meantime, for anybody else tripping over this, I worked around it by encodeObject: NSStringFromCGPoint(point) forKey: locationKey Cheers, . . . . . . . .Henry = iPhone App Development and Developer Education . . . Visit www.nonatomic-retain.com Mac OSX Application Development, Plus a Great Deal More . . . Visit www.trilithon.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Setting the Line Height/ Line Spacing in an NSTextView.
How would I set the Line Height/ Line Spacing in an NSTextView? e.g How tall each line is or how much space is between each line. Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
n00b Q re: AppController
my carbon app loads a couple plugins, which use Cocoa. each plugin implements AppController. should they? i get this in my log upon launch: objc[17568]: Class AppController is implemented in both /Library/Application Support/kJams/Burner.bundle/Contents/MacOS/Burner and /Library/Application Support/kJams/Producer.bundle/Contents/MacOS/Producer. One of the two will be used. Which one is undefined. seems like something ain't right there...___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Setting the Line Height/ Line Spacing in an NSTextView.
Use a paragraph style. Douglas Davidson On Dec 24, 2009, at 10:25 AM, Joshua Garnham joshua.garn...@yahoo.co.uk wrote: How would I set the Line Height/ Line Spacing in an NSTextView? e.g How tall each line is or how much space is between each line. Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/ddavidso%40apple.com This email sent to ddavi...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] NSKeyedArchiver with NSValue Objects
On Dec 24, 2009, at 09:59, Henry McGilton (Boulevardier) wrote: I bashed into a problem with NSKeyedArchiver trying to encode NSValue objects. I am using NSValue to wrap up CGPoint and CGSize structures, then doing an encodeObject: forKey: to encode the NSValue. I get this message: [NSKeyedArchiver encodeValueOfObjCType:at:]: this archiver cannot encode structs' I poked around in CocoaBuilder and Google for some definitive answers, but the discussions appear to be mostly froth. This seems a little strange, as UIKit provides a bunch of NSValue additions to encode those CG structs, but the NSKeyedArchiver can't encode them. And the message is somewhat misleading: I'm encoding the NSValue object, not the structure . . .I'm assuming (I know, one should never assume) that the NSValue object is invoking that encodeValueOfObjCType:at: message . . . NSValue objects are not in suitable for archiving because there's no API contract that says they'll deal with byte ordering issues for you. (And, in fact, they couldn't, for structs in general.) If you're dealing with NSPoint and NSSize, you can use -[NSKeyedArchiver encodePoint/Size: forKey:], but you're crossing framework boundaries (a little bit) with CGPoint and CGSize, so you have an extra step. Either convert to NSPoint/NSSize and use the matching NSKeyedArchiver method, or encode the two structure components as numbers. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] NSKeyedArchiver with NSValue Objects
Also since you are crossing the boundaries of the framework to UIKit you could also use the NSStringFromCGRect/CGPoint and CGRect/CGPointFromNSString and encoding strings. Again you will have an extras step to go back and forth. --Waqar On Dec 24, 2009, at 12:47 PM, Quincey Morris wrote: On Dec 24, 2009, at 09:59, Henry McGilton (Boulevardier) wrote: I bashed into a problem with NSKeyedArchiver trying to encode NSValue objects. I am using NSValue to wrap up CGPoint and CGSize structures, then doing an encodeObject: forKey: to encode the NSValue. I get this message: [NSKeyedArchiver encodeValueOfObjCType:at:]: this archiver cannot encode structs' I poked around in CocoaBuilder and Google for some definitive answers, but the discussions appear to be mostly froth. This seems a little strange, as UIKit provides a bunch of NSValue additions to encode those CG structs, but the NSKeyedArchiver can't encode them. And the message is somewhat misleading: I'm encoding the NSValue object, not the structure . . .I'm assuming (I know, one should never assume) that the NSValue object is invoking that encodeValueOfObjCType:at: message . . . NSValue objects are not in suitable for archiving because there's no API contract that says they'll deal with byte ordering issues for you. (And, in fact, they couldn't, for structs in general.) If you're dealing with NSPoint and NSSize, you can use -[NSKeyedArchiver encodePoint/Size: forKey:], but you're crossing framework boundaries (a little bit) with CGPoint and CGSize, so you have an extra step. Either convert to NSPoint/NSSize and use the matching NSKeyedArchiver method, or encode the two structure components as numbers. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSCollectionView NSArrayController bindings from outer hell
On Dec 24, 2009, at 05:06, Nicolas Berloquin wrote: The strange thing is that once I made the changes, it still didn't work. I had to remove then recreate the NSCollectionView and all the views and arraycontroller in IB before it worked right. Or maybe the chickens helped :) One of NSCollectionView's many bugs (under Leopard -- I gave up ever trying to use it, so I don't know its Snow Leopard behavior) was that establishing of bindings defined in the prototype object *failed* at nib-loading time, depending on the order of the objects in the nib. This meant that simply editing the xib (for any reason) could break it, and editing the xib again could make it work. That's likely why recreating the view worked -- just because you edited the xib. The next time you edit the xib it might break again. Or maybe the chickens *will* help. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Releasing Objects
On Dec 24, 2009, at 12:47 AM, Ken Thomases wrote: On Dec 24, 2009, at 2:23 AM, John Engelhart wrote: Wait, what? I could understand that under GC -retain might be nothing more than the equivalent of - (id)retain { return(self); }, but -retainCount? Is it really - (NSUInteger)retainCount { return((NSUInteger)self); } ? Wouldn't it make more sense to just return 1, or maybe something like NSUIntegerMax? There is no implementation of -retainCount under GC. There's a short-circuit in obj_msgSend that detects the selector for the memory management methods which are no-ops. Since -retain and -autorelease have to return self, that's what the short-circuit does. -retainCount gets the same treatment and so the same return value. The return value doesn't matter, anyway. (Frankly, it hardly matters under managed memory, either.) More precisely, there's exactly one short-circuit check and thus only one selector value. Under GC, @selector(retain) == @selector(release) == @selector(autorelease) == @selector(dealloc) == @selector(retainCount). Happily, `return self` works to implement all of those. Don't write any code that relies on those selectors being equal, though. It will change in the future. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
MallocDebug Hang with Core Data Save
Start with an Apple core data document based application project template. Build and start with performance tool MallocDebug. Launch and check for leaks. Back in core data app save file. Update to check for leaks and MallocDebug will hang. Happens on PPC and Intel, Xcode 3.1.4, MallocDebug 1.7.1. Anyone else having trouble with this? --Richard Partial crash report Date/Time: 2009-12-24 15:58:29 -0700 OS Version: 10.5.8 (Build 9L30) Architecture: ppc Report Version: 4 Command:MallocDebug Path: /Developer/Applications/Performance Tools/ MallocDebug.app/Contents/MacOS/MallocDebug Version:1.7.1 (89) Build Version: 331 Project Name: MallocDebug Source Version: 89 Parent: Xcode [129] PID:561 Event: hang Time: 6.62s Steps: 31 Process:MallocDebug [561] Path: /Developer/Applications/Performance Tools/ MallocDebug.app/Contents/MacOS/MallocDebug ADDRESS BINARY 1000/Developer/Applications/Performance Tools/ MallocDebug.app/Contents/MacOS/MallocDebug 00027000/Developer/Applications/Performance Tools/ MallocDebug.app/Contents/MacOS/../../../../../Library/ PrivateFrameworks//DevToolsRemoteClient.framework/Versions/A/ DevToolsRemoteClient 00065000/System/Library/PrivateFrameworks/vmutils.framework/ Versions/A/vmutils 000ca000/Developer/Applications/Performance Tools/ MallocDebug.app/Contents/MacOS/../../../../../Library/ PrivateFrameworks//DevToolsFoundation.framework/Versions/A/ DevToolsFoundation 0010c000/System/Library/PrivateFrameworks/ Symbolication.framework/Versions/A/Symbolication 00197000/System/Library/PrivateFrameworks/ DebugSymbols.framework/Versions/A/DebugSymbols 0330e000/System/Library/CoreServices/RawCamera.bundle/ Contents/MacOS/RawCamera Thread id: 2c18af8 User stack: 31 ??? [0x20d0] 31 _NSApplicationMain + 444 (in AppKit) [0x9645329c] 31 -[NSApplication run] + 804 (in AppKit) [0x964828d8] 31 -[NSApplication sendEvent:] + 3260 (in AppKit) [0x96515680] 31 -[NSWindow sendEvent:] + 4516 (in AppKit) [0x965422dc] 31 -[NSControl mouseDown:] + 808 (in AppKit) [0x96543a18] 31 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 520 (in AppKit) [0x965440dc] 31 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1588 (in AppKit) [0x965447a4] 31 -[NSControl sendAction:to:] + 96 (in AppKit) [0x9654528c] 31 -[NSApplication sendAction:to:from:] + 108 (in AppKit) [0x96545358] 31 ??? [0x6fcc] 31 ??? [0x645c] 31 ??? [0x15974] 31 ??? [0x2738] 31 _mach_msg_trap + 8 (in libSystem.B.dylib) [0x955e81f8] END ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Releasing Objects
On Thu, Dec 24, 2009 at 5:13 PM, Greg Parker gpar...@apple.com wrote: More precisely, there's exactly one short-circuit check and thus only one selector value. Under GC, @selector(retain) == @selector(release) == @selector(autorelease) == @selector(dealloc) == @selector(retainCount). Happily, `return self` works to implement all of those. Just out of curiosity, is that really a short-circuit in the message-passing machinery, or are all those selectors simply registered to point to the same IMP function? A useless bit of knowledge for us end-users, I know, but interesting just the same. Greg Parker gpar...@apple.com Runtime Wrangler I think that should be Wruntime Wrangler. :-) sherm-- -- Cocoa programming in Perl: http://www.camelbones.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: n00b Q re: AppController
On Dec 23, 2009, at 6:37 PM, David M. Cotter wrote: my carbon app loads a couple plugins, which use Cocoa. each plugin implements AppController. should they? i get this in my log upon launch: objc[17568]: Class AppController is implemented in both /Library/Application Support/kJams/Burner.bundle/Contents/MacOS/Burner and /Library/Application Support/kJams/Producer.bundle/Contents/MacOS/Producer. One of the two will be used. Which one is undefined. seems like something ain't right there... In Objective-C all classes share a namespace, so if two binary images are loaded into the same address space, and use the same class name, then one of the two classes will be used. If all of these AppControllers share the same functionality, then you probably won't have any issues (for now) but if all of your plugins do implement this class to the same function, then you should probably abstract them all into a common framework that all of these plugins load instead. -- David Duncan Apple DTS Animation and Printing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [textView:shouldChangeTextInRanges:replacementStrings:] When does this type of event occur?
How about replace all? I haven't done any text programming so I'm not sure how much functionality the API offers. So this is purely a guess :) On 24/12/2009, at 19:39 , Iceberg-Dev wrote: On Dec 23, 2009, at 10:58 PM, Dave DeLong wrote: In many apps, you can hold down the option key to change the cursor into a crosshair, and do a vertical selection. In addition, in apps like Pages, you can hold down the command key to do a non-contiguous selection. I'd imagine that both of these scenarios might result in that method getting invoked. That explains how to get a non-continuous selection but not how you can change the text in multiple locations. Let's say you have a non-continuous selection and you type or paste some text, it just delete the selection and insert the new text in the first selection range (tested in TextEdit). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/brian%40darknova.com This email sent to br...@darknova.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Releasing Objects
On 24 dec 2009, at 15.16, Sherm Pendley wrote: Just out of curiosity, is that really a short-circuit in the message-passing machinery, or are all those selectors simply registered to point to the same IMP function? A useless bit of knowledge for us end-users, I know, but interesting just the same. Short circuited. See: http://www.friday.com/bbum/2009/12/18/objc_msgsend-tour-part-3-the-fast-path/ j o a r ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is there a warning for this?
On 25/12/2009, at 01:20 , Kyle Sluder wrote: On Dec 24, 2009, at 3:26 AM, Brian Bruinewoud br...@darknova.com wrote: Is there some way to turn on a warning saying 'you are directly accessing an ivar where a (non-trivial) getter/setter exists'? I'm assuming you're targeting iPhone OS. If you can deal with not running your code in the simulator, switching to synthesized ivars where possible might avoid this situation in most cases, since you would either need self. or self- to access the property/ivar. Otherwise, give your ivars a prefix (underscore is verboten according to Apple, since they use it in the frameworks). Oh, and if not being able to use the new runtime (and therefore synthesized ivars) in the simulator bothers you, file a bug. Same with the lack of namespacing leading to rules like thou shalt not prefix identifiers with underscores. If enough of us complain about something, Apple might take our opinions into consideration. --Kyle Sluder Thanks Kyle and Alexander. I am indeed targeting iPhone OS in this particular example, though I didn't think that was particularly relevant. Would your answer change if I wasn't (other than discussing the simulator's limitations, obviously)? Looks like I'll get into the habit of giving iVars a prefix or using synthesis where possible. Thanks, Brian.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableview datasource issues
Actually the reloadData and datasource issues with NSTableView are reported often. Please try to google or bing these issues and you will be amazed on how many complaints are out there. Xcode could for example flag the datasource method where I had capitalized objectValueForTableColumn, either by pointing out that the method does not exist in interface or that I need to implement datasource methods correctly. Unfortunately, sometimes one may not share all the code for confidentiality reasons. As you said, one bites the bullet, rewrites the code, and moves on. Thanks again. -Original Message- From: Greg Guerin [mailto:glgue...@amug.org] Sent: Thursday, December 24, 2009 12:21 PM To: 'list-cocoa-dev' Subject: Re: NSTableview datasource issues ... The issue is that reloadData was not launching datasource methods, regardless. ... My concern though: how come Xcode does not flag issues with datasource? What is so strange is that [segmentTableView editColumn:k row:i withEvent:nil select:YES] was launching the datasource methods, whereas reloadData was not.What would Xcode do, debug the code by itself?If reloadData was the actual cause of the bug, then why isn't this problem reported more often? Surely, you're not the only one using reloadData.There was obviously some kind of bug in the code or in its connections to other things. Finding out exactly what that bug is would require the full source project of the malfunctioning program. If you haven't saved that, then the information is lost forever. If you have saved it, then send it in a bug report to Apple. You can also post the zipped project somewhere like pastebin.com and post the URL to the list. Anyone who's interested can then attack the problem.Every programmer eventually creates code that they themselves can't debug. Sometimes the bug isn't found despite considerable effort, and a rewrite ensues. Sometimes another programmer finds the bug, but I've never seen that happen without the source. Occasionally the bug is eventually found by its creator, and with luck, it's accompanied by a profound feeling of revelation, even epiphany. One doesn't always have the time, though, so sometimes one must rewrite and move on. -- GG___Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)Please do not post admin requests or moderator comments to the list.Contact the moderators at cocoa-dev-admins(at)lists.apple.comHelp/Unsubscribe/Update your Subscription:http://lists.apple.com/mailman/options/cocoa-dev/aronisoft%40afroamerica.netThis email sent to aronis...@afroamerica.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Releasing Objects
On Thu, Dec 24, 2009 at 7:36 PM, Joar Wingfors j...@joar.com wrote: On 24 dec 2009, at 15.16, Sherm Pendley wrote: Just out of curiosity, is that really a short-circuit in the message-passing machinery, or are all those selectors simply registered to point to the same IMP function? A useless bit of knowledge for us end-users, I know, but interesting just the same. Short circuited. See: http://www.friday.com/bbum/2009/12/18/objc_msgsend-tour-part-3-the-fast-path/ Wow, that's a *fascinating* read! Thanks! sherm-- -- Cocoa programming in Perl: http://www.camelbones.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableview datasource issues
On Dec 24, 2009, at 8:34 PM, aronis...@afroamerica.net wrote: Xcode could for example flag the datasource method where I had capitalized objectValueForTableColumn, either by pointing out that the method does not exist in interface or that I need to implement datasource methods correctly. The incorrect capitalization should have triggered an undeclared selector warning. Building with errors as warnings will prevent these warnings from slipping through the cracks. As for implementing the methods correctly, there is only so much the compiler can do. It can't verify your program operates correctly; it can make sure you have implemented all the required methods of a formal protocol, but NSTableView's datasource methods only became a formal protocol in the 10.6 SDK. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
IPhone- Datasensitive bug from CoreData...
This has me totally stumped. I have an app that contains (currently) three Entities: Person Deed; and DeedDoneByPerson Deed is effectively a template object. I'll probably re-do the object model but I want to understand what's going on with this bug first. Deeds can be good or not and have a degree of goodness. Here is the code that creates a new deed and deedDoneByPerson: NSManagedObject *newDeed = [ NSEntityDescription insertNewObjectForEntityForName: @Deed inManagedObjectContext: context ]; int score; if( self.isGood ) score = sender.tag; else score = - sender.tag; [newDeed setValue: self.deedName.text forKey: @deedName ]; [newDeed setValue: [ NSNumber numberWithBool: self.isGood ] forKey: @isGood ]; [newDeed setValue: [ NSNumber numberWithInt: score ] forKey: @points ]; NSManagedObject *newDeedDoneByPerson = [ NSEntityDescription insertNewObjectForEntityForName: @DeedDoneByPerson inManagedObjectContext: context ]; [newDeedDoneByPerson setValue: newDeed forKey: @deedDone ]; [newDeedDoneByPerson setValue: selectedPerson forKey: @byPerson ]; [newDeedDoneByPerson setValue: [ NSNumber numberWithBool: self.isGood ] forKey: @isGood ]; // let 'points' and 'instances' default FYI2( @:: Create new deed [...@], self.deedName.text ); NSError *error; if (![context save:error]) //!!! CRASHES HERE { NSLog(@!! Unresolved error %@, %@, error, [error userInfo]); abort(); } The following scenarios work: With a fresh app (deleted from the simulator and re-installed), create a person and add any number of bad deeds to that person - they are displayed correctly and sqlite has the expected contents. With a fresh app (deleted from the simulator and re-installed), create a person and add any number of good deeds to that person - they are displayed correctly and sqlite has the expected contents. With a fresh app (deleted from the simulator and re-installed), create a person and add any number of bad deeds to that person - they are displayed correctly and sqlite has the expected contents. Then create another person and add any number of good deeds to that person - they are displayed correctly and sqlite has the expected contents The following scenario does NOT work: With a fresh app (deleted from the simulator and re-installed), create a person and add a bad deed to that person then attempt to add a good deed. BOOM Stack trace: #0 0x93affedb in objc_msgSend #1 0x939f4b6c in ?? #2 0x0001763a in _nsnote_callback #3 0x01d34005 in _CFXNotificationPostNotification #4 0x00014ef0 in -[NSNotificationCenter postNotificationName:object:userInfo:] #5 0x01ba717d in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] #6 0x01c06763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] #7 0x01b8b5ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] #8 0x01bc1728 in -[NSManagedObjectContext save:] #9 0x5434 in -[NewDeedViewController commit:] at NewDeedViewController.m:131 --- CODE ABOVE #10 0x00298459 in -[UIApplication sendAction:to:from:forEvent:] #11 0x002fbba2 in -[UIControl sendAction:to:forEvent:] #12 0x002fddc3 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] #13 0x002fcb0f in -[UIControl touchesEnded:withEvent:] #14 0x002b1e33 in -[UIWindow _sendTouchesForEvent:] #15 0x0029b81c in -[UIApplication sendEvent:] #16 0x002a20b5 in _UIApplicationHandleEvent #17 0x0252cef1 in PurpleEventCallback #18 0x01d40b80 in CFRunLoopRunSpecific #19 0x01d3fc48 in CFRunLoopRunInMode #20 0x0252b7ad in GSEventRunModal #21 0x0252b872 in GSEventRun #22 0x002a3003 in UIApplicationMain #23 0x1cb4 in main at main.m:14 I don't understand how the value of 'score' breaks things. If I get rid of the negation in this code: int score; if( self.isGood ) score = sender.tag; else score = - sender.tag; everything works fine: adding good and bad to the same person is acceptable. Any suggestions on what to investigate? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription:
Re: Releasing Objects
On Dec 24, 2009, at 3:16 PM, Sherm Pendley wrote: On Thu, Dec 24, 2009 at 5:13 PM, Greg Parker gpar...@apple.com wrote: More precisely, there's exactly one short-circuit check and thus only one selector value. Under GC, @selector(retain) == @selector(release) == @selector(autorelease) == @selector(dealloc) == @selector(retainCount). Happily, `return self` works to implement all of those. Just out of curiosity, is that really a short-circuit in the message-passing machinery, or are all those selectors simply registered to point to the same IMP function? A useless bit of knowledge for us end-users, I know, but interesting just the same. Both. There are an extra two instructions at the start of most flavors of objc_msgSend(). That's intended to do nothing fast. The method lookup machinery also recognizes that selector value, and hands back a `return self` IMP. That's for the benefit of code that looks up IMPs and calls them directly. The second half was missing at one point during Leopard development. Some code was looking up IMPs for -retain and -release. But under GC the methods named above share the same selector value, so the runtime handed back the first method in the class's method list with that selector. For most classes this is the -dealloc implementation. Hilarity ensued. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: IPhone- Datasensitive bug from CoreData...
Oh, sorry, here is the message in the Console: *** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70 Serious application error. Exception was caught during Core Data change processing: *** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70 with userInfo (null) *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70' Stack: ( ... On 25/12/2009, at 16:40 , Brian Bruinewoud wrote: This has me totally stumped. I have an app that contains (currently) three Entities: Person Deed; and DeedDoneByPerson Deed is effectively a template object. I'll probably re-do the object model but I want to understand what's going on with this bug first. Deeds can be good or not and have a degree of goodness. Here is the code that creates a new deed and deedDoneByPerson: NSManagedObject *newDeed = [ NSEntityDescription insertNewObjectForEntityForName: @Deed inManagedObjectContext: context ]; int score; if( self.isGood ) score = sender.tag; else score = - sender.tag; [newDeed setValue: self.deedName.text forKey: @deedName ]; [newDeed setValue: [ NSNumber numberWithBool: self.isGood ] forKey: @isGood ]; [newDeed setValue: [ NSNumber numberWithInt: score ] forKey: @points ]; NSManagedObject *newDeedDoneByPerson = [ NSEntityDescription insertNewObjectForEntityForName: @DeedDoneByPerson inManagedObjectContext: context ]; [newDeedDoneByPerson setValue: newDeed forKey: @deedDone ]; [newDeedDoneByPerson setValue: selectedPerson forKey: @byPerson ]; [newDeedDoneByPerson setValue: [ NSNumber numberWithBool: self.isGood ] forKey: @isGood ]; // let 'points' and 'instances' default FYI2( @:: Create new deed [...@], self.deedName.text ); NSError *error; if (![context save:error]) //!!! CRASHES HERE { NSLog(@!! Unresolved error %@, %@, error, [error userInfo]); abort(); } The following scenarios work: With a fresh app (deleted from the simulator and re-installed), create a person and add any number of bad deeds to that person - they are displayed correctly and sqlite has the expected contents. With a fresh app (deleted from the simulator and re-installed), create a person and add any number of good deeds to that person - they are displayed correctly and sqlite has the expected contents. With a fresh app (deleted from the simulator and re-installed), create a person and add any number of bad deeds to that person - they are displayed correctly and sqlite has the expected contents. Then create another person and add any number of good deeds to that person - they are displayed correctly and sqlite has the expected contents The following scenario does NOT work: With a fresh app (deleted from the simulator and re-installed), create a person and add a bad deed to that person then attempt to add a good deed. BOOM Stack trace: #00x93affedb in objc_msgSend #10x939f4b6c in ?? #20x0001763a in _nsnote_callback #30x01d34005 in _CFXNotificationPostNotification #40x00014ef0 in -[NSNotificationCenter postNotificationName:object:userInfo:] #50x01ba717d in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] #60x01c06763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] #70x01b8b5ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] #80x01bc1728 in -[NSManagedObjectContext save:] #90x5434 in -[NewDeedViewController commit:] at NewDeedViewController.m:131 --- CODE ABOVE #10 0x00298459 in -[UIApplication sendAction:to:from:forEvent:] #11 0x002fbba2 in -[UIControl sendAction:to:forEvent:] #12 0x002fddc3 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] #13 0x002fcb0f in -[UIControl touchesEnded:withEvent:] #14 0x002b1e33 in -[UIWindow _sendTouchesForEvent:] #15 0x0029b81c in -[UIApplication sendEvent:] #16 0x002a20b5 in _UIApplicationHandleEvent #17 0x0252cef1 in PurpleEventCallback #18 0x01d40b80 in CFRunLoopRunSpecific #19 0x01d3fc48 in CFRunLoopRunInMode #20 0x0252b7ad in GSEventRunModal #21 0x0252b872 in GSEventRun #22 0x002a3003 in UIApplicationMain #23 0x1cb4 in main at main.m:14 I don't understand how the value of 'score'
Re: IPhone- Datasensitive bug from CoreData...
Final set of information for today. Sometimes the console just had INVALID INSTRUCTION without any error message. Mostly its the below error message but with different target objects. The latest was UIImageView - as far as I know, I have no UIImageVIew in my app (unless it's part of the implementation of another control/view, which makes sense). Finally, another scenario that works: With a fresh app (deleted from the simulator and re-installed), create a person and add a bad deed to that person. Quit and restart the app then attempt to add a good deed. Success. It seems that the bug is triggered when: 1. Adding to the same user 2. In the same session (ie, without quiting the app in between) 3. A new deed that has a score where sign(new-score) != sign(previous-score) :-( Until tomorrow... On 25/12/2009, at 16:48 , Brian Bruinewoud wrote: Oh, sorry, here is the message in the Console: *** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70 Serious application error. Exception was caught during Core Data change processing: *** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70 with userInfo (null) *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType controllerDidChangeContent:]: unrecognized selector sent to instance 0x3a11d70' Stack: ( ... On 25/12/2009, at 16:40 , Brian Bruinewoud wrote: This has me totally stumped. I have an app that contains (currently) three Entities: Person Deed; and DeedDoneByPerson Deed is effectively a template object. I'll probably re-do the object model but I want to understand what's going on with this bug first. Deeds can be good or not and have a degree of goodness. Here is the code that creates a new deed and deedDoneByPerson: NSManagedObject *newDeed = [ NSEntityDescription insertNewObjectForEntityForName: @Deed inManagedObjectContext: context ]; int score; if( self.isGood ) score = sender.tag; else score = - sender.tag; [newDeed setValue: self.deedName.text forKey: @deedName ]; [newDeed setValue: [ NSNumber numberWithBool: self.isGood ] forKey: @isGood ]; [newDeed setValue: [ NSNumber numberWithInt: score ] forKey: @points ]; NSManagedObject *newDeedDoneByPerson = [ NSEntityDescription insertNewObjectForEntityForName: @DeedDoneByPerson inManagedObjectContext: context ]; [newDeedDoneByPerson setValue: newDeed forKey: @deedDone ]; [newDeedDoneByPerson setValue: selectedPerson forKey: @byPerson ]; [newDeedDoneByPerson setValue: [ NSNumber numberWithBool: self.isGood ] forKey: @isGood ]; // let 'points' and 'instances' default FYI2( @:: Create new deed [...@], self.deedName.text ); NSError *error; if (![context save:error]) //!!! CRASHES HERE { NSLog(@!! Unresolved error %@, %@, error, [error userInfo]); abort(); } The following scenarios work: With a fresh app (deleted from the simulator and re-installed), create a person and add any number of bad deeds to that person - they are displayed correctly and sqlite has the expected contents. With a fresh app (deleted from the simulator and re-installed), create a person and add any number of good deeds to that person - they are displayed correctly and sqlite has the expected contents. With a fresh app (deleted from the simulator and re-installed), create a person and add any number of bad deeds to that person - they are displayed correctly and sqlite has the expected contents. Then create another person and add any number of good deeds to that person - they are displayed correctly and sqlite has the expected contents The following scenario does NOT work: With a fresh app (deleted from the simulator and re-installed), create a person and add a bad deed to that person then attempt to add a good deed. BOOM Stack trace: #0 0x93affedb in objc_msgSend #1 0x939f4b6c in ?? #2 0x0001763a in _nsnote_callback #3 0x01d34005 in _CFXNotificationPostNotification #4 0x00014ef0 in -[NSNotificationCenter postNotificationName:object:userInfo:] #5 0x01ba717d in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] #6 0x01c06763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] #7 0x01b8b5ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] #8 0x01bc1728 in -[NSManagedObjectContext