Re: Handling errors in -initWithCoder:
On Mar 12, 2009, at 21:05, Graham Cox wrote: One of my classes can sometimes fail in -initWithCoder: - it relies on certain resources being available and if it doesn't get them, I thought I could follow the same pattern as -init and autorelease self and return nil. When I do this though I get an error from the dearchiver, like: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:]: number of objects (0) not equal to number of keys (298) This prevents the remainder of the archive from loading, which I don't want. What's a good way to handle this? I would prefer that my object isn't created at all if possible, but that the archive loads what it can. It's hard to handle this in the class that owns this, because it's just an array of objects. I'm thinking I need some post-processing that goes through and weeds out certain flagged objects, but maybe there's a better way? If you ever return nil from initWithCoder, it's likely your decoded data model is screwed beyond the point of recovery, if the failure is on one of the objects in a collection (which is apparently what's happening above). Therefore, if you need to salvage (the rest of) your decoded model, you can't return nil on failure, but must return a crippled (==flagged) object, or a proxy object, with just enough behavior to allow the rest of the model to be unarchived, and deal with the problem after unarchiving is complete. So, yes, weeding out flagged objects seems like a good way to do it. ___ 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
How to use MySql, which api is for that
Hi, Actually i searched for this and i got lots of posting about MySql but these are very old. i followed some posting also. Like i found http://mysql-cocoa.sourceforge.net/downloads.html; and we can use this mySql Api for our application. I downloaded this api and documentation. They have mention that use SMySQL_bundled.framework but i didn't find this framework in their folder. and one MCPKit.xcodproj is also there...but this is also not workinglots of errors are coming. Anybody does know about this then pls share ur knowledge. Thanks, Haresh. ___ 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
UIPickerView Caching Items
Hi all, I am doing a bit of prototype testing and have coded a small iPhone app that browses Bonjour services. On the interface I have currently just added a UIPickerView which dynamically at runtime gets items added to it as and when my NSNetServiceBrowser finds services. When the browser finds a service it simple calls: [services addObject:aNetService]; [aNetService resolveWithTimeout:5.0]; [uiPickerView reloadAllComponents]; And my UIPickerViewDelegate methods perform the following: - ( NSString * )pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { NSNetService* service = [[bonjourDiscoveryService services] objectAtIndex:row]; return [service name]; } This is working fine but I have noticed something strange. If I turn stop the bonjour service on an already displayed service the UIPickerView successfully removes it from the lists. But, then if I change the service name and restart the Bonjour service the UIPickerView adds the service but with the old service name? Does the iPhone have some form of caching objects?? Many thanks all, Eggsy _ Free photo editing software from Windows Live . Try it now! http://clk.atdmt.com/UKM/go/134665240/direct/01/___ 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: NSWorkspaceWillPowerOffNotification from a daemon
It seems your situation is similar to this: http://lists.apple.com/archives/macnetworkprog/2007/Aug/msg00017.html I just tested, and a normal (non-daemon) Cocoa app _does_ receive the power-off event. It sounds like daemons in particular have an issue receiving it. It appears that IOKit has something called kIOMessageSystemWillPowerOff. Check out /Developer/Examples/IOKit/FireWire/FWLib. You'll probably need to change the project to write the output to a file, or something. Once you've done that, shut down your computer. When you reboot, whatever log file was created should mention something about kIOMessageSystemWillPowerOff. How does this suite your needs? It's definitely not as elegant as NSNotifications, but it's probably more robust. David ___ 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: Getting the front process path
Try: NSDictionary *frontAppInfo = [[NSWorkspace sharedWorkspace] activeApplication]; NSString *pathToActiveApp = [frontAppInfo objectForKey: @NSApplicationPath]; NSLog(@%@, pathToActiveApp); ___ 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
NSManagedObject validateForDelete problem
I'm attempting to use NSManagedObject validateForDelete in order to provide timely feedback to delete actions by users. But the relationship delete rules don't seem to be getting applied as I would expect. As a toy example I created a simple CoreData app with two entities, Department and Employee --employees and department are the respective inverse relationships. The delete rule for Department employees to Employee department is Cascade. The delete rule for Employee department to Department employees is Nullify. I was expecting that if I had a single Department with a single Employee, then validateForDelete would return true on both of these managed objects. But it doesn't. Can someone clear up my apparent misunderstanding, or suggest a better way of accomplishing my goal? In the context of this example, if Employee had a relationship to a third entity (say, a Stapler entity) with a delete rule of Deny, if the user attempted to delete the Employee's Department I would like to tell the user they must first delete the Employee's Stapler. If they did that, then I'd like deleting the Department to cascade to deleting the Employee. Here's my test code: NSManagedObject *department = [NSEntityDescription insertNewObjectForEntityForName:@Department inManagedObjectContext:moc]; NSError *error; BOOL canDelete = [department validateForDelete:error]; NSLog(@1) For department canDelete = %d, canDelete); if (! canDelete) NSLog(@\terror = %@, [error localizedDescription]); NSManagedObject *employee = [NSEntityDescription insertNewObjectForEntityForName:@Employee inManagedObjectContext:moc]; canDelete = [employee validateForDelete:error]; NSLog(@2) For employee canDelete = %d, canDelete); if (! canDelete) NSLog(@\terror = %@, [error localizedDescription]); [employee setDepartment:department]; canDelete = [department validateForDelete:error]; NSLog(@3) For department canDelete = %d, canDelete); if (! canDelete) NSLog(@\terror = %@, [error localizedDescription]); canDelete = [employee validateForDelete:error]; NSLog(@4) For employee canDelete = %d, canDelete); if (! canDelete) NSLog(@\terror = %@, [error localizedDescription]); And the resulting log output (removing the log statement data part for brevity): 1) For department canDelete = 1 2) For employee canDelete = 1 3) For department canDelete = 0 error = Items cannot be deleted from employees. 4) For employee canDelete = 0 error = Items cannot be deleted from department. Thanks for any help, Ward ___ 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: Performance problem with GC enabled
On Mar 12, 2009, at 8:39 AM, Bill Bumgarner wrote: On Mar 12, 2009, at 6:04 AM, John Engelhart wrote: [ way too many words deleted ... please try to succinctly state issues in the future ] You have created a micro benchmark that demonstrates a significant bit of overhead from GC vs. non-GC. He extracted a real-world example of a performance problem into an isolated test case. This is a good thing. While micro benchmarks are certainly useful, they must be taken with a grain of salt. Specifically, a real world app is not generally going to go do, say, 10 bazillion of the operations in the micro benchmark one after the other with zero feedback to the user. Since the reported performance is relative, the scale-factor in front is quite irrelevant. If you run it 10 times or 10 bazillion times, 2.8x slower is still 2.8x slower. However, having a large scale- factor is convenient for taking meaningful measurements of running time. Typically, a real world app would have progress bar(s), live button (s), and displays that are updated. So things that are not impacted by the GC dilute the effect? GC was optimized for the real world situation. This is not an 'optimization'. This is just saying that computers today are fast enough that for many non-data-intensive applications, there will be enough idle-time for the machine to catch up that people won't notice wether operations are 2.8x slower. In Leopard, the GC overhead is generally less than 10% CPU overhead and 10% memory footprint overhead for the whole application. While such sweeping generalizations can be useful, they must be taken with a grain of salt. In some specific measurements [of Xcode, for example, comparing GC vs. non-GC performance], GC is actually significantly more efficient than non-GC. Is that actually true? In others, non-GC is still quite a bit more efficient. But, overall and for the general user experience, GC on Leopard beats the general 10%/10% mark. Is that for operations that actually use GC, or does that also include operations that do not involve the GC at all? And, just like every other component of Mac OS X, the goal is to make the collector faster, more efficient, easier to use, and more powerful with each successive release of Mac OS X. Excellent! Marcel ___ 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: TXT Records with NSImages
Just got recently into that pit myself. Read the docs _very_ carefully for this one. (And file a complaint at the bottom of the doc’s page) dictionaryFromTXTRecordData: Return Value A dictionary representing txtData. The dictionary’s keys are NSStringobjects using UTF8 encoding. The _values_ associated with all the dictionary’s keys _are NSData_ objects that encapsulate strings or data If you feed your NSDictionary anything else than NSData it will return nil. So you just have to convert your image to NSData and store that. atze Am 13.03.2009 um 03:45 schrieb Joe Turner: Hello, Recently, I've been working on an app that will sync with an iphone app. So, I am using NSNetServices. I would like the iPhone to display the mac's icon, so I was thinking of using the TXT Record to store the icon. However, whenever I add it to the dictionary, convert the dictionary to data (using the NSNetService methd), it becomes nil. I am guessing that's because it's too large. Then, I decided to set the size of the image to (1,1) thinking it must be small enough. However, I still got nil. Is there a way to send an NSImage (as NSData in the dictionary, PNG formatted using an NSImageRep then converted to data) through a TXTRecord. And, if so, is there a way for the image to be able to be displayed on the iphone? I know an NSImage cannot be displayed on the iphone, which is why I converted it to PNG data, hoping the iphone could read that. Thanks! Joe ___ 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/atze%40freeport.de This email sent to a...@freeport.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
RE: NSTableView live resizing glitch
Corbin, Please take a look at the bug with ID 6677201 and also feel free to check out the email I sent you yesterday. Stay in touch. Meanwhile, I rather like Chris' approach because it works :) Thanks, U From: corb...@apple.com Date: Thu, 12 Mar 2009 16:06:11 -0700 To: csu...@sutes.co.uk CC: cocoa-dev@lists.apple.com Subject: Re: NSTableView live resizing glitch On Mar 12, 2009, at 3:50 PM, Chris Suter wrote: Hi Ulai, On Fri, Mar 13, 2009 at 9:33 AM, Ulai Beekam wrote: I'm having an NSTableView live resizing glitch that is driving me nuts. Please see this image: http://img15.imageshack.us/img15/2012/picture1tcz.png I really need to have the column width independent of the table view's size, so it is not an option to have the column resize with the table. But here is the strangest thing of all: This glitch appears only when the table view's focus ring is set to None. The glitch goes away if the focus ring is set to default! Any ideas on how to fix this live resizing glitch would be greatly appreciated. I've worked around similar issues in some code I wrote. Try subclassing NSTableView and then in the tile method, after calling [super tile], do this: [[self headerView] setNeedsDisplay:YES]; That's doing too much redraw work :) -- you can introduce performance problems by calling setNeedsDisplay: too often. Please do log bugs when you run into these issues. I think there may be an off-by-one issue in the OS that Ulai is using. I would need a proper bug report with system information to validate that. If my first suggestion doesn't fix it, then redrawing the last rect with a setNeedsDisplayInRect: via -tile will work, so your work around is a good suggestion (with a slight mod to not redraw the whole thing). corbin ___ 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/ulaibeekam%40hotmail.com This email sent to ulaibee...@hotmail.com _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us___ 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: Performance problem with GC enabled
On Mar 12, 2009, at 10:54 AM, Bill Bumgarner wrote: On Mar 12, 2009, at 10:29 AM, John Engelhart wrote: Actually, this isn't a micro-benchmark. If you aren't displaying the results, responding to user events, keeping an application state up to date and otherwise doing all of the things that need be done in a real world application, it is -- effectively -- a micro-benchmark. LOL! There are applications that need to do intensive data processing. These applications are NOT micro-benchmarks. I bet Google would be somewhat surprised to find that all they are doing all day is running microbenchmarks. In the context of an application, such processing is likely to be on a secondary thread and there is likely to be synchronization of data between threads. The overhead of the write barrier (which is spin lock contention under the covers, most likely) will be somewhat offset by the vast decrease in the cost of moving objects between threads, for example. The synchronization overhead for moving progress updates across threads every 10th of a second is negligible unless you're doing something very very wrong. Having the processing 2.8x slower will not be helped by putting the processing on a background thread: you will still have to wait 2.8x longer for your results. Your app may be responsive during that time, but that is of dubious value if you are waiting for results. Think about processing HTTP server logs, and then performing more regex operations the further massage the end results (ie, the host only portion of the referrer). Sure -- and if I were writing a Cocoa application to do exactly that, it would be doing all kinds of UI updates during the process to keep the user up to date on progress, give them a feel for whether the analysis is moving along in the correct direction, etc,etc,etc and all of that graphics related chatter is very likely going to far outweigh the CPU cycles consumed by the actual data processing bit. Not if you're doing it right. If I were writing a command line tool to process log files in batches -- which I have done many times on the scale of 10s of GB of logs produced per day -- I wouldn't use Cocoa or Objective-C at all. This makes me very sad. I *would* use Objective-C for data-intensive processing, wether in command-line or GUI apps or servers, and have done so in the past with great success, but it looks like you're quite happy to relegate Objective-C to the role of a toy/glue language for hooking up GUIs, incapable of handling the demands actual data processing. What makes this even more ironic is that Objective-C was specifically created to provide high performance, and is absolutely capable of doing so. Don't get me wrong -- I'm not saying that you haven't found a particular test where, at the extreme, It is only extreme if you consider any type of data-intensive processing 'extreme'. Regards, Marcel ___ 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: NSManagedObject validateForDelete problem
I'm attempting to use NSManagedObject validateForDelete in order to provide timely feedback to delete actions by users. But the relationship delete rules don't seem to be getting applied as I would expect. -validateForDelete: is intended as a potential delegate hook for subclasses of NSManagedObject. It's designed to be called from within -save: to perform any customized validation you might need on deleted objects. It's not intended to double as -canDelete or -isDeleteable. It will produce something vaguely to that effect if you call - processPendingChanges first, although that's not its purpose. - Ben ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Performance problem with GC enabled
Bill said something in passing on this issue which I think is important. To paraphrase: If you care about performance, don't use the Cocoa RegEx stuff to parse large amounts of data. I think this observation is true whether you use GC or not. GC just makes it worse. I'd like to see a pure-C benchmark of the original test, perhaps just from the command line using egrep. I suspect the results would be startling. Having said all of which, I think the original test is not unfair and I agree with a lot of the points people have made in support of that view. It's always painful to have to step outside the Cocoa frameworks, and (off topic) it seems that GC can make it more so. I for one will not be using it. Rgds - Paul Sanders. ___ 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
Singleton Help ...
Hi, I've been looking into creating a singleton class to manage some objects that I have that I'd like to be globally available. I've been reading through http://www.cocoadev.com/index.pl?SingletonDesignPattern and all looks well except I now have the following question ... I'd like my singleton to observe the NSWorkspace notifications applicationDidLaunch and applicationDidTerminate. I can setup the observations in the init method, but how to I go about removing them ? You would normally do in the dealloc method, but it seems you're not meant to override dealloc in a singleton ? Would it suffice to put them in the overridden release method ? If so, does this get called automatically when I close the application ? If I can't remove the notifications, I could end up with the notification centre try to foward them to an object that no longer exists. Thanks -Mic ___ 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
[CA] zPosition + mask + animation = no animation
Hi list's readers, I'm encountering a weird issue by using a masked, animated, z-positionned layer within an animated context: the layer's animation does run only when the context's animation does. The thing is when I deactivate the layer's mask, it works; when I delete the z-position setting of all the layers in the context, it works. At first I thought it could be a media timing function issue because both animations does not have the same one (respectively kCAMediaTimingFunctionLinear vs. the default one – I guess it's kCAMediaTimingFunctionEaseInEaseOut), but it seems wrong. Thanks for any help :) Best, Paul Arthur Henrion snip ___ 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: Singleton Help ...
By definition, if it's a singleton, it will exist for the lifetime of the program; there is no risk of the notification centre sending messages to a now non-existent object. On 13 Mar 2009, at 10:31, Mic Pringle wrote: Hi, I've been looking into creating a singleton class to manage some objects that I have that I'd like to be globally available. I've been reading through http://www.cocoadev.com/index.pl?SingletonDesignPattern and all looks well except I now have the following question ... I'd like my singleton to observe the NSWorkspace notifications applicationDidLaunch and applicationDidTerminate. I can setup the observations in the init method, but how to I go about removing them ? You would normally do in the dealloc method, but it seems you're not meant to override dealloc in a singleton ? Would it suffice to put them in the overridden release method ? If so, does this get called automatically when I close the application ? If I can't remove the notifications, I could end up with the notification centre try to foward them to an object that no longer exists. Thanks -Mic ___ 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: Singleton Help ...
But I thought that it was best practice to remove yourself from the notification center before terminating your application, as doesn't the notification center live in the objective-c runtime and therefore is always active, regardless of whether your application is or isn't ? -Mic 2009/3/13 Mike Abdullah cocoa...@mikeabdullah.net: By definition, if it's a singleton, it will exist for the lifetime of the program; there is no risk of the notification centre sending messages to a now non-existent object. On 13 Mar 2009, at 10:31, Mic Pringle wrote: Hi, I've been looking into creating a singleton class to manage some objects that I have that I'd like to be globally available. I've been reading through http://www.cocoadev.com/index.pl?SingletonDesignPattern and all looks well except I now have the following question ... I'd like my singleton to observe the NSWorkspace notifications applicationDidLaunch and applicationDidTerminate. I can setup the observations in the init method, but how to I go about removing them ? You would normally do in the dealloc method, but it seems you're not meant to override dealloc in a singleton ? Would it suffice to put them in the overridden release method ? If so, does this get called automatically when I close the application ? If I can't remove the notifications, I could end up with the notification centre try to foward them to an object that no longer exists. Thanks -Mic ___ 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: Singleton Help ...
I'm pretty sure the run-time will sort that all out for you. But I'm a bit confused here - if you're getting an applicationDidTerminate notification, why not just remove them there anyway? Sandy On Mar 13, 2009, at 12:54 PM, Mic Pringle wrote: But I thought that it was best practice to remove yourself from the notification center before terminating your application, as doesn't the notification center live in the objective-c runtime and therefore is always active, regardless of whether your application is or isn't ? -Mic 2009/3/13 Mike Abdullah cocoa...@mikeabdullah.net: By definition, if it's a singleton, it will exist for the lifetime of the program; there is no risk of the notification centre sending messages to a now non-existent object. On 13 Mar 2009, at 10:31, Mic Pringle wrote: Hi, I've been looking into creating a singleton class to manage some objects that I have that I'd like to be globally available. I've been reading through http://www.cocoadev.com/index.pl?SingletonDesignPattern and all looks well except I now have the following question ... I'd like my singleton to observe the NSWorkspace notifications applicationDidLaunch and applicationDidTerminate. I can setup the observations in the init method, but how to I go about removing them ? You would normally do in the dealloc method, but it seems you're not meant to override dealloc in a singleton ? Would it suffice to put them in the overridden release method ? If so, does this get called automatically when I close the application ? If I can't remove the notifications, I could end up with the notification centre try to foward them to an object that no longer exists. Thanks -Mic ___ 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/mcguffogl%40gmail.com This email sent to mcguff...@gmail.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: Singleton Help ...
The Oobj runtime is a C library loaded by each ObjC application, it's not an autonome entity that lives beyond your application termination. Le 13 mars 09 à 11:54, Mic Pringle a écrit : But I thought that it was best practice to remove yourself from the notification center before terminating your application, as doesn't the notification center live in the objective-c runtime and therefore is always active, regardless of whether your application is or isn't ? -Mic 2009/3/13 Mike Abdullah cocoa...@mikeabdullah.net: By definition, if it's a singleton, it will exist for the lifetime of the program; there is no risk of the notification centre sending messages to a now non-existent object. On 13 Mar 2009, at 10:31, Mic Pringle wrote: Hi, I've been looking into creating a singleton class to manage some objects that I have that I'd like to be globally available. I've been reading through http://www.cocoadev.com/index.pl?SingletonDesignPattern and all looks well except I now have the following question ... I'd like my singleton to observe the NSWorkspace notifications applicationDidLaunch and applicationDidTerminate. I can setup the observations in the init method, but how to I go about removing them ? You would normally do in the dealloc method, but it seems you're not meant to override dealloc in a singleton ? Would it suffice to put them in the overridden release method ? If so, does this get called automatically when I close the application ? If I can't remove the notifications, I could end up with the notification centre try to foward them to an object that no longer exists. Thanks -Mic ___ 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/devlists%40shadowlab.org This email sent to devli...@shadowlab.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: Singleton Help ...
Because it's the applicationDidTerminate notification from NSWorkspace, informing me about other applications closing, not my own. -Mic 2009/3/13 Sandy McGuffog mcguff...@gmail.com: I'm pretty sure the run-time will sort that all out for you. But I'm a bit confused here - if you're getting an applicationDidTerminate notification, why not just remove them there anyway? Sandy On Mar 13, 2009, at 12:54 PM, Mic Pringle wrote: But I thought that it was best practice to remove yourself from the notification center before terminating your application, as doesn't the notification center live in the objective-c runtime and therefore is always active, regardless of whether your application is or isn't ? -Mic 2009/3/13 Mike Abdullah cocoa...@mikeabdullah.net: By definition, if it's a singleton, it will exist for the lifetime of the program; there is no risk of the notification centre sending messages to a now non-existent object. On 13 Mar 2009, at 10:31, Mic Pringle wrote: Hi, I've been looking into creating a singleton class to manage some objects that I have that I'd like to be globally available. I've been reading through http://www.cocoadev.com/index.pl?SingletonDesignPattern and all looks well except I now have the following question ... I'd like my singleton to observe the NSWorkspace notifications applicationDidLaunch and applicationDidTerminate. I can setup the observations in the init method, but how to I go about removing them ? You would normally do in the dealloc method, but it seems you're not meant to override dealloc in a singleton ? Would it suffice to put them in the overridden release method ? If so, does this get called automatically when I close the application ? If I can't remove the notifications, I could end up with the notification centre try to foward them to an object that no longer exists. Thanks -Mic ___ 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/mcguffogl%40gmail.com This email sent to mcguff...@gmail.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
why can't I see my layer?
I have a simple setup below, but I can't see my text layer, what am I missing? (also are all of the commented lines nessecary?) view= [[[NSApplication sharedApplication] keyWindow] contentView]; rootLayer = [CALayer layer]; [rootLayer setBounds: NSRectToCGRect(view.bounds)]; // is this necessary? [rootLayer setMasksToBounds:NO]; // or could I omit the line above and just do this? [rootLayer setPosition:CGPointMake(0, 0)]; // i guess this is not needed? CATextLayer *titleLayer = [CATextLayer layer]; titleLayer.string = @testing this; titleLayer.font = [NSFont fontWithName:@Myriad Set size:20]; titleLayer.foregroundColor = CGColorCreateGenericRGB(.2, .3, .9, 1.0); [rootLayer addSublayer:titleLayer]; [view setLayer:rootLayer]; [view setWantsLayer:YES]; [view setNeedsDisplay:YES]; // is this necessary? [rootLayer setNeedsDisplay]; // is this necessary? instead of adding titleLayer to rootLayer, if I directly do view.layer = titleLayer I can see it (so nothing wrong with titleLayer), but obviously then I can't add more stuff, I need to add stuff to the root... Cheers, Memo. ___ 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: TXT Records with NSImages
Actually, I am converting it to NSData, and then adding it, and it still returns nil Joe On Mar 13, 2009, at 3:27 AM, Alexander Spohr wrote: Just got recently into that pit myself. Read the docs _very_ carefully for this one. (And file a complaint at the bottom of the doc’s page) dictionaryFromTXTRecordData: Return Value A dictionary representing txtData. The dictionary’s keys are NSStringobjects using UTF8 encoding. The _values_ associated with all the dictionary’s keys _are NSData_ objects that encapsulate strings or data If you feed your NSDictionary anything else than NSData it will return nil. So you just have to convert your image to NSData and store that. atze Am 13.03.2009 um 03:45 schrieb Joe Turner: Hello, Recently, I've been working on an app that will sync with an iphone app. So, I am using NSNetServices. I would like the iPhone to display the mac's icon, so I was thinking of using the TXT Record to store the icon. However, whenever I add it to the dictionary, convert the dictionary to data (using the NSNetService methd), it becomes nil. I am guessing that's because it's too large. Then, I decided to set the size of the image to (1,1) thinking it must be small enough. However, I still got nil. Is there a way to send an NSImage (as NSData in the dictionary, PNG formatted using an NSImageRep then converted to data) through a TXTRecord. And, if so, is there a way for the image to be able to be displayed on the iphone? I know an NSImage cannot be displayed on the iphone, which is why I converted it to PNG data, hoping the iphone could read that. Thanks! Joe ___ 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/atze%40freeport.de This email sent to a...@freeport.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: TXT Records with NSImages
On Fri, Mar 13, 2009 at 8:12 AM, Joe Turner joetur...@me.com wrote: Actually, I am converting it to NSData, and then adding it, and it still returns nil Post code. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: code for drawing an NSTextField to a panel window ...
On Fri, Mar 13, 2009 at 8:01 AM, vinai for_use...@yahoo.com wrote: Hi All, Thanks for your feedback. I AM coming from a non-Cocoa background, and I was hoping to keep some picture of how the GUI was interacting with my code at a fairly low level. Crawl before you walk, walk before you run. Writing your GUI in code is a useful and educational exercise. But it will only be useful and educational if you do it *after* you are already proficient with the standard way of doing things. Get good with the basics (which means using nibs), and once you're comfortable with that, you'll be in a much better position to go off and experiment with code-based GUIs, if you should still feel a desire to. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: TXT Records with NSImages
Joe, That's a lot of data to be storing in the TXT record. I'd advise that you store it in the NULL record as iChat does for 'Bonjour' chat. Keith ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: TXT Records with NSImages
Here: NSImage *original = [NSImage imageNamed:NSImageNameComputer]; [original setSize:NSMakeSize(10.0f, 10.0f)]; NSData *image = [original TIFFRepresentation]; NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:image]; NSData *finalData = [imageRep representationUsingType:NSPNGFileType properties:nil]; NSDictionary *txtRecord = [NSDictionary dictionaryWithObject:finalData forKey:@image]; NSData *data = [NSNetService dataFromTXTRecordDictionary:txtRecord]; if (data) NSLog(@Data is not nil!); [netService setTXTRecordData:data]; Joe On Mar 13, 2009, at 7:30 AM, Michael Ash wrote: On Fri, Mar 13, 2009 at 8:12 AM, Joe Turner joetur...@me.com wrote: Actually, I am converting it to NSData, and then adding it, and it still returns nil Post code. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/joeturner%40me.com This email sent to joetur...@me.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 Singleton Help ...
I had a very similar situation using a singleton and found that I needed to remove it from the notification centre before the app died - or landed up with an odd side effect (main menu items in xCode would no longer respond to the mouse ). I fixed it by getting the app delegate to respond to applicationShouldTerminate: and removed my singleton from the notification centre there. The menu problems went away. PH ___ 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
NSPredicate live filtering question
Hi, I'm belatedly dipping my toes into NSPredicate to do some array filtering. I have an array of objects which have (among other things) a boolean property. In my UI, I have three tables: 1) The first table has all the entries in the array. 2) The second table uses an NSPredicate to filter the array and show only the entries where the boolean property is true. 3) The third table is the opposite of #2, it shows entries where the boolean property is false. For clarity: I'm using a unique NSArrayController for each of the above, instantiated in my nib file. So on load, the boolean property is set by some simple image processing ( I'm filtering a folder of images into two sets based on analysis of the images' pixels ). So far, this works. I see the right images showing up in the aforementioned tables. However, I'd like to be able to manually override the results of the image processing -- say due to false positive or whatever -- and as such I put a checkbox in the first table ( the all table ) which toggles that boolean property. The trouble is that toggling that boolean property on an entry doesn't update the contents of the two filtered arrays. I figure there's got to be some way to make the array controllers for those filtered tables know that the values have changed. In the past, I've done some kind of hacky stuff to make this work, such as binding a faux property in my app/doc controller to the array controller using arrangeObjects.propertyName -- then in my +initialize method I passed those faux properties to setKeys: triggerChangeNotificationsForDependentKey: to get the change recognized. If something like that's really the only way to go, then that's fine. But I feel like there's got to be some way that's a little more elegant. Note: I'm not using core data -- my model is just an NSArray of my image processing objects. Thanks in advance, shamyl zakariya authentic frontier gibberish ___ 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: Re Singleton Help ...
Similarly, couldn't you have the singleton itself register to receive the applicationWillTerminate notification? I don't think it has to be done via the app's delegate. Something like: (in your singleton's accessor, or perhaps a private initializer?) [[NSNotificationCenter defaultCenter] addObserver:_singletonInstance selector:@selector(appIsQuitting:) name: NSApplicationWillTerminateNotification object:NSApp]; Then in your appIsQutting: method, just do: [[NSNotificationCenter defaultCenter] removeObserver:self]; HTH, Dave On Mar 13, 2009, at 6:49 AM, Peter Hudson wrote: I had a very similar situation using a singleton and found that I needed to remove it from the notification centre before the app died - or landed up with an odd side effect (main menu items in xCode would no longer respond to the mouse ). I fixed it by getting the app delegate to respond to applicationShouldTerminate: and removed my singleton from the notification centre there. The menu problems went away. PH ___ 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: Re Singleton Help ...
Yep. This looks like the best solution. Will give this a go. Thanks -Mic 2009/3/13 Dave DeLong davedel...@me.com: Similarly, couldn't you have the singleton itself register to receive the applicationWillTerminate notification? I don't think it has to be done via the app's delegate. Something like: (in your singleton's accessor, or perhaps a private initializer?) [[NSNotificationCenter defaultCenter] addObserver:_singletonInstance selector:@selector(appIsQuitting:) name: NSApplicationWillTerminateNotification object:NSApp]; Then in your appIsQutting: method, just do: [[NSNotificationCenter defaultCenter] removeObserver:self]; HTH, Dave On Mar 13, 2009, at 6:49 AM, Peter Hudson wrote: I had a very similar situation using a singleton and found that I needed to remove it from the notification centre before the app died - or landed up with an odd side effect (main menu items in xCode would no longer respond to the mouse ). I fixed it by getting the app delegate to respond to applicationShouldTerminate: and removed my singleton from the notification centre there. The menu problems went away. PH ___ 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/micpringle%40gmail.com This email sent to micprin...@gmail.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: code for drawing an NSTextField to a panel window ...
Writing your GUI in code is a useful and educational exercise. But it will only be useful and educational if you do it *after* you are already proficient with the standard way of doing things. Get good with the basics (which means using nibs), and once you're comfortable with that, you'll be in a much better position to go off and experiment with code-based GUIs, if you should still feel a desire to. Yes, I would second that. I am coming to Cocoa from a Windows background and face many of the same issues as vinai. I found getting to grips with Interface Builder to be very educational, and it's not so hard to figure out what is going on behind the scenes. Doing this has also influenced my thinking on how best to port my app across. Something I found very helpful is the way Xcode will set you up a minimal app with all the standed connections and menu items in place. I would recommend starting there vinai. Rgds - Paul Sanders.. ___ 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: why can't I see my layer?
for others reading this on the archives, I found the problem, I need to set the bounds (or frame) for titleLayer. On 13 Mar 2009, at 12:09, Memo Akten wrote: I have a simple setup below, but I can't see my text layer, what am I missing? (also are all of the commented lines nessecary?) view= [[[NSApplication sharedApplication] keyWindow] contentView]; rootLayer = [CALayer layer]; [rootLayer setBounds: NSRectToCGRect(view.bounds)]; // is this necessary? [rootLayer setMasksToBounds:NO]; // or could I omit the line above and just do this? [rootLayer setPosition:CGPointMake(0, 0)]; // i guess this is not needed? CATextLayer *titleLayer = [CATextLayer layer]; titleLayer.string = @testing this; titleLayer.font = [NSFont fontWithName:@Myriad Set size:20]; titleLayer.foregroundColor = CGColorCreateGenericRGB(.2, .3, .9, 1.0); [rootLayer addSublayer:titleLayer]; [view setLayer:rootLayer]; [view setWantsLayer:YES]; [view setNeedsDisplay:YES]; // is this necessary? [rootLayer setNeedsDisplay]; // is this necessary? instead of adding titleLayer to rootLayer, if I directly do view.layer = titleLayer I can see it (so nothing wrong with titleLayer), but obviously then I can't add more stuff, I need to add stuff to the root... Cheers, Memo. ___ 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/memo%40memo.tv This email sent to m...@memo.tv ___ 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: NSPredicate live filtering question
I think in order for this to work you have to makesure you have a key/value compliant getter setter for the boolean value and then in the code you have to use [someObject setValue: ForKey:]; This will then notify any observers (i.e your array controller) that the value has changed and update it accordingly. -Mic 2009/3/13 Shamyl Zakariya sha...@gmail.com: Hi, I'm belatedly dipping my toes into NSPredicate to do some array filtering. I have an array of objects which have (among other things) a boolean property. In my UI, I have three tables: 1) The first table has all the entries in the array. 2) The second table uses an NSPredicate to filter the array and show only the entries where the boolean property is true. 3) The third table is the opposite of #2, it shows entries where the boolean property is false. For clarity: I'm using a unique NSArrayController for each of the above, instantiated in my nib file. So on load, the boolean property is set by some simple image processing ( I'm filtering a folder of images into two sets based on analysis of the images' pixels ). So far, this works. I see the right images showing up in the aforementioned tables. However, I'd like to be able to manually override the results of the image processing -- say due to false positive or whatever -- and as such I put a checkbox in the first table ( the all table ) which toggles that boolean property. The trouble is that toggling that boolean property on an entry doesn't update the contents of the two filtered arrays. I figure there's got to be some way to make the array controllers for those filtered tables know that the values have changed. In the past, I've done some kind of hacky stuff to make this work, such as binding a faux property in my app/doc controller to the array controller using arrangeObjects.propertyName -- then in my +initialize method I passed those faux properties to setKeys: triggerChangeNotificationsForDependentKey: to get the change recognized. If something like that's really the only way to go, then that's fine. But I feel like there's got to be some way that's a little more elegant. Note: I'm not using core data -- my model is just an NSArray of my image processing objects. Thanks in advance, shamyl zakariya authentic frontier gibberish ___ 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/micpringle%40gmail.com This email sent to micprin...@gmail.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
cocoa file APIs
Just trying to figure out what the best APIs are to use for some pretty simple file operations. I've found NSFileHandle, NSFileManager, or I could use low-level C-apis or a combination of the two. What I want to do is create and write binary files (and I guess read them again later). I'd also like to be able to create temporary files in whatever the proper temporary location is, use them and delete them (or have them auto-delete) seems like NSFileHandle fileHandleForWritingAtPath: doesn't create the file if it doesn't exist so I have to open it first with a open() and wrap it or use NSFileManager createFileAtPath:contents:attributes .. however I don't actually have any contents at this point (I'm going to be creating it later) and wanted some control over whether files are replaced etc. so open() actually looks better for this. I was trying to find an API which gives me the correct path for temporary files, or even a temporary filename, but haven't found one. Am I looking at the right APIs and thinking about this the right way, or are there some other cocoa classes I should be looking at. I'll happily use open() etc but wanted something higher-level and insulated from the filesystem if cocoa provides it. ___ 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: cocoa file APIs
On 14/03/2009, at 12:44 AM, Roland King wrote: I was trying to find an API which gives me the correct path for temporary files, or even a temporary filename, but haven't found one. NSTemporaryDirectory Am I looking at the right APIs and thinking about this the right way, or are there some other cocoa classes I should be looking at. I'll happily use open() etc but wanted something higher-level and insulated from the filesystem if cocoa provides it.___ For binary data, one very simple solution is to use NSData - writeToFile:atomically: For deletion, copying, etc, NSFileManager is probably the highest level. --Graham ___ 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: TXT Records with NSImages
On Fri, Mar 13, 2009 at 8:45 AM, Joe Turner joetur...@me.com wrote: Here: NSImage *original = [NSImage imageNamed:NSImageNameComputer]; [original setSize:NSMakeSize(10.0f, 10.0f)]; NSData *image = [original TIFFRepresentation]; NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:image]; NSData *finalData = [imageRep representationUsingType:NSPNGFileType properties:nil]; NSDictionary *txtRecord = [NSDictionary dictionaryWithObject:finalData forKey:@image]; NSData *data = [NSNetService dataFromTXTRecordDictionary:txtRecord]; if (data) NSLog(@Data is not nil!); [netService setTXTRecordData:data]; That all looks fine (except for the manipulation of the original image, which could be a shared object; make a copy, manipulate that) but I just remembered something from the Zeroconf spec: The format of each constituent string within the DNS TXT record is a single length byte, followed by 0-255 bytes of text data. In other words, the total length of each TXT record entry, counting the key, the value, and the equals sign that separates them, cannot exceed 255 bytes. You'll either have to *really* shrink your picture, or find another way to transmit it. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextFieldCell text color issue in NSTableView with source list highlighting
On 12 Mar 2009, at 17:07, Corbin Dunn wrote: On Mar 12, 2009, at 3:51 AM, jonat...@mugginsoft.com wrote: The recommended way to override the text color in an NSTableView NSTextFieldCell is detailed here: http://www.cocoabuilder.com/archive/message/cocoa/2008/11/5/222008. However, there seems to be a problem setting the text color of a highlighted NSTextFieldCell when NSTableView - selectionHighlightStyle is set to NSTableViewSelectionHighlightStyleSourceList. The following delegate method produces uneven text coloration of highlighted text cells. The issue does not arise for non source list style NSTableViews. /* tableview will display cell */ - (void)tableView:(NSTableView *)aTableView willDisplayCell: (id)aCell forTableColumn:(NSTableColumn *)aTableColumn row: (NSInteger)rowIndex { // note that when the NSTableView Highlight mode is set to source list // setting the text color of NSTextFieldCell seems to misbehave. if ([aCell isKindOfClass:[NSTextFieldCell class]]) { if ([aCell isHighlighted]) { [aCell setTextColor: [NSColor lightGrayColor]]; } else { [aCell setTextColor: [NSColor darkGrayColor]]; } } } Has anyone else encountered this? Work around solution is probably to use NSAttributedString. That is the only solution at the time. Could you log a bug for this? Bug logged. Bug ID: 6679161 NSTableView attempts to apply standard attributes for the highlighted cell, if plain text is given to the cell via the datasource. corbin Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Handling errors in -initWithCoder:
On Mar 13, 2009, at 12:05 AM, Graham Cox wrote: Minor problem, I think, but I'd like to get some advice about the right way to approach this. One of my classes can sometimes fail in -initWithCoder: - it relies on certain resources being available and if it doesn't get them, I thought I could follow the same pattern as -init and autorelease self and return nil. When I do this though I get an error from the dearchiver, like: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:]: number of objects (0) not equal to number of keys (298) This prevents the remainder of the archive from loading, which I don't want. What's a good way to handle this? I would prefer that my object isn't created at all if possible, but that the archive loads what it can. It's hard to handle this in the class that owns this, because it's just an array of objects. I'm thinking I need some post-processing that goes through and weeds out certain flagged objects, but maybe there's a better way? You could set some flag in initWithCoder: and then return nil from awakeAfterUsingCoder: when the flag is set. Cheers, M ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to use MySql, which api is for that
SMySQL_bundled.framework is list on that page ( http://mysql-cocoa.sourceforge.net/downloads.html ) under Binary files. it's grayed out and listed as deprecated but still available for download. I linked it into a fresh project and it complied successfully. hope that helps +Clint On Fri, Mar 13, 2009 at 1:32 AM, haresh vavdiya vavdiyahar...@gmail.comwrote: Hi, Actually i searched for this and i got lots of posting about MySql but these are very old. i followed some posting also. Like i found http://mysql-cocoa.sourceforge.net/downloads.html; and we can use this mySql Api for our application. I downloaded this api and documentation. They have mention that use SMySQL_bundled.framework but i didn't find this framework in their folder. and one MCPKit.xcodproj is also there...but this is also not workinglots of errors are coming. Anybody does know about this then pls share ur knowledge. Thanks, Haresh. ___ 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/cts3e1%40gmail.com This email sent to cts...@gmail.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: [CA] zPosition + mask + animation = no animation
Hi, This sounds like a framework bug. Please file a bug report so we can make sure it gets fixed (if possible including a test case showing the issue). thanks, John On Mar 13, 2009, at 3:49 AM, Paul Arthur Henrion wrote: Hi list's readers, I'm encountering a weird issue by using a masked, animated, z- positionned layer within an animated context: the layer's animation does run only when the context's animation does. The thing is when I deactivate the layer's mask, it works; when I delete the z-position setting of all the layers in the context, it works. At first I thought it could be a media timing function issue because both animations does not have the same one (respectively kCAMediaTimingFunctionLinear vs. the default one – I guess it's kCAMediaTimingFunctionEaseInEaseOut), but it seems wrong. Thanks for any help :) Best, Paul Arthur Henrion snip ___ 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/jsh%40apple.com This email sent to j...@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
Trying to write icon data to file
I'm putting together some code that will write an icon file (obtained via NSWorkspace) to a gif. I had prototyped the code with a simple command-line tool with hard-coded values for file sources, destinations, and image sizes. However, when I try to abstract the code, I am now getting weird error messages: Error: CGImageCreate: invalid image size: 0 x 0. 2009-03-13 10:40:48.805 Wish[20760:10b] Could not create CGImageRef - w:0, h:0, bps:8, bpp:32, bpr:512, alpha:0x1, cSpace:NSCalibratedRGBColorSpace, hasAlpha:1, isPlanar:0 Fri Mar 13 10:40:48 Macintosh.local Wish[20760] Error: CGImageDestinationFinalize image destination does not have enough images CGImageDestinationFinalize failed for output type 'com.compuserve.gif' objc[20760]: FREED(id): message release sent to freed object=0x466430 The basic code is below: -(int) makeIcon: (NSString *) filePath imagewidth: (float) width imageheight: (float)height outputfile:(NSString *)imagePath { NSApplicationLoad(); //set up autorelease pool NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; //retrieve the icon NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:filePath]; //get bitmap representation of icon NSBitmapImageRep *resizeicon = (NSBitmapImageRep *)[icon bestRepresentationForDevice:nil]; //set the icon size [resizeicon setSize:NSMakeSize(width, height)]; [resizeicon setPixelsWide: width]; [resizeicon setPixelsHigh:height]; //convert icon to gif, write to file [[resizeicon representationUsingType:NSGIFFileType properties:nil] writeToFile:imagePath atomically:NO]; //release memory [icon release]; [resizeicon release]; [pool release]; return 0; } The prototype code, below, actually works as designed, so I'm not sure what the problem is. Any advice is appreciated. #import Cocoa/Cocoa.h int main (int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:@/Applications/AppKiDo.app]; NSBitmapImageRep *resizeicon = (NSBitmapImageRep *)[icon bestRepresentationForDevice:nil]; [resizeicon setSize:NSMakeSize(48.0, 48.0)]; [resizeicon setPixelsWide:48.0]; [resizeicon setPixelsHigh:48.0]; [[resizeicon representationUsingType:NSGIFFileType properties:nil] writeToFile:@/Users/kevin/Desktop/bar.gif atomically:NO]; [pool release]; return 0; } Thanks -- Kevin Walzer Code by Kevin http://www.codebykevin.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: Performance problem with GC enabled
On Mar 13, 2009, at 2:28 AM, Paul Sanders wrote: Having said all of which, I think the original test is not unfair and I agree with a lot of the points people have made in support of that view. It's always painful to have to step outside the Cocoa frameworks, and (off topic) it seems that GC can make it more so. I for one will not be using it. Having written a ton of code that sits on the border between GC and non-GC, I don't find that GC makes the code any more difficult to write along that particular border.It does, however, make it considerably more difficult to debug certain kinds of problems related to memory management (and this is an area for which a lot of effort has been expended to improve the experience on Snow Leopard -- if you have access to the seed, please go poke at it and provide feedback). Under non-GC, that border is either: - retain/release/autorelease vs. cfretain/cfrelease or - retain/release/autorelease vs. malloc/free or - retain/release/autorelease vs. some random memory management module specific to C++ and/or library you are working with Under GC, the retain/release/autorelease part goes away, obviously. This leaves the right hand side relatively unchanged saved for where it integrates into the code. The most complex change is the move from -dealloc to -finalize. Finalizers are executed in an effectively random order whereas many people seem to want deallocs to be executed in a fixed, dependent, order. In reality, incurring order dependencies on -dealloc is a really bad idea; one unexpected -retain [leak] or -autorelease [order change] and the house of cards falls over (this has been a *huge* debugging time sink, in my experience). Finalizers force the issue by making ordered execution nearly impossible to achieve. --- Beyond owning non-GC'd stuff in GC'd memory, there is the reverse issue.There is virtually no difference between non-GC and GC in this regard.If you are shoving a random object reference into non- ObjC data structures, through non-ObjC APIs, under non-GC, you need to -retain on entrance and -release on exit to be safe. Whether you call -retain/-release in your wrapper around the non-ObjC API or modify the non-ObjC API to call -retain/-release internally is entirely an implementation detail. Moving to GC doesn't really change anything beyond the need to use CFRetain() / CFRelease() instead of -retain/-release. Since you can use CFRetain/CFRelease in the non-GC case, replacing -retain/-release in such contexts (-autorelease is generally to be avoided in such places with CFRetain/CFRelease makes for nearly no difference. Of course, you could choose to go down the route of using the various APIs to allocated collectable/scanned memory while using __strong and __weak to make the non-ObjC code more GC friendly. There will be an ever growing performance gain to be had in doing so, but it is very hard to get right. (The ObjC garbage collector is not actually an ObjC garbage collector -- it is entirely language agnostic. The ObjC part is that it is fully automatic with Objective-C, but must be manually integrated with everything else.) --- Thus, it comes down to an issue of debugging. And, frankly, in Leopard, debugging that border is hard. Harder than non-GC, but not significantly so.In both cases, the use of MallocStackLoggingNoCompact, the resulting malloc histories, and related tools is critical. The bugs at the border will typically be premature destruction of memory and knowing the history of a pointer that causes a crash later will typically point to exactly where the premature destruction occurred. As you said, going from Cocoa to non-Cocoa is a pain. GC changes the pain a bit, making it slightly worse in some ways. Personally, I find that developing Cocoa applications using GC is so much faster and more pleasant than non-GC, that the relatively minor additional border pain is easily outweighed by the advantages of using GC on the pure Cocoa side. b.bum ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Trying to write icon data to file
On Mar 13, 2009, at 7:57 AM, Kevin Walzer wrote: I'm putting together some code that will write an icon file (obtained via NSWorkspace) to a gif. I had prototyped the code with a simple command-line tool with hard- coded values for file sources, destinations, and image sizes. However, when I try to abstract the code, I am now getting weird error messages: Error: CGImageCreate: invalid image size: 0 x 0. 2009-03-13 10:40:48.805 Wish[20760:10b] Could not create CGImageRef - w:0, h:0, bps:8, bpp:32, bpr:512, alpha:0x1, cSpace:NSCalibratedRGBColorSpace, hasAlpha:1, isPlanar:0 Log your width and height values to see what they really are. You appear to be using 0, 0. Incidentally, setPixelsWide: and setPixelsHigh: do not do what you appear to think they do. You could also check [icon isValid] to make sure the image is available. objc[20760]: FREED(id): message release sent to freed object=0x466430 This is because you are incorrectly managing memory for icon and resizeicon. Check the docs on that again. -- Adam smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSButton manual drawing
Hi, I am drawing controls into view to use as feedback during Drag Drop operation. I've tried to draw manually a NSButton (with NSRoundedBezelStyle) using [[button cell] drawWithFrame:frame inView:[NSView focusView]]; I obtain a button image with the correct background, but the button text is at the bottom. When I add the button to the view it is correctly displayed. Am I doing something wrong, since this method seems to work for popup buttons ? Thanks, Yvan ___ 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
Binding to selection of NSArrayController manually
Hello everybody Bindings problem: I have an NSArrayController subclass and an NSPopUpButton subclass. I am trying to bind the NSPopUpButton's selected object to the selection of my array controller. I have to do this manually for reasons I won't get into here. But when I do this (self is myPopUpButton) [self bind:@selectedObject toObject:ArrayController withKeyPath:@selection options:nil]; I get the error that my array controller is not KVC for the key path selection. selection is definitely a controller key option in Interface Builder, is it possible that this doesn't work programmatically? Has anyone else run into this problem??? I want to bind to the selected object, not the index... so it seems my only option here is selectedObjects, which I will have to pass an array of one object to. Ivy Feraco UI Developer i...@boxstudios.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: Performance problem with GC enabled
The most complex change is the move from -dealloc to -finalize. Finalizers are executed in an effectively random order whereas many people seem to want deallocs to be executed in a fixed, dependent, order. In reality, incurring order dependencies on -dealloc is a really bad idea; one unexpected -retain [leak] or -autorelease [order change] and the house of cards falls over (this has been a *huge* debugging time sink, in my experience). Finalizers force the issue by making ordered execution nearly impossible to achieve. Yes, I agree with that (just got bitten by that one in fact). In the world I am used to, destructors get called in a deterministic fashion (which I like), but even in autorelease world you can't rely on that. For example, when an NSWindow is release-on-closed, it gets dealloc'd, I just discovered, *before* the NSViews it contains. This strikes me as dangerous actually, as the NSViews might feel they are entitled to refer to the NSWindow in which they reside until they are deallocated, but that seems to be the way it works. Of course, you could choose to go down the route of using the various APIs to allocated collectable/scanned memory while using __strong and __weak to make the non-ObjC code more GC friendly. There will be an ever growing performance gain to be had in doing so, but it is very hard to get right. (The ObjC garbage collector is not actually an ObjC garbage collector -- it is entirely language agnostic. The ObjC part is that it is fully automatic with Objective-C, but must be manually integrated with everything else.) Judging by a recent thread on this topic, it sounds safer to manage 'legacy' mallocs / new's yourself. I personally wouldn't want the garbage collector to interfere with this. But I haven't read the docs so I don't know what the garbage collector brings to the party. The bugs at the border will typically be premature destruction of memory. Ouch! Sounds like the key thing is a thorough understanding of how it works. I think ought to add that I am not using GC primarily because I want my code to run on Tiger. I can see that it will be a big win for many Cocoa programmers. (Off topic again): Call me old-fashioned, but I don't like autorelease pools all that much. I believe Cocoa could have gotten along just fine without them, had they never been invented. I prefer C++-style 'smart pointers' that delete (or release) themselves when they go out of scope. That way you avoid the loss of determinism and potential memory usage peaks that autorelease pools introduce and it's really not painful writing code that way. It's a pity that Objective-C doesn't support such a construct - life would have been so much easier. But it's far too late now. Rgds - Paul Sanders. ___ 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: Binding to selection of NSArrayController manually
On Mar 13, 2009, at 9:42 AM, Ivy Feraco wrote: Hello everybody Bindings problem: I have an NSArrayController subclass and an NSPopUpButton subclass. I am trying to bind the NSPopUpButton's selected object to the selection of my array controller. I have to do this manually for reasons I won't get into here. But when I do this (self is myPopUpButton) [self bind:@selectedObject toObject:ArrayController withKeyPath:@selection options:nil]; I get the error that my array controller is not KVC for the key path selection. selection is definitely a controller key option in Interface Builder, is it possible that this doesn't work programmatically? Has anyone else run into this problem??? I want to bind to the selected object, not the index... so it seems my only option here is selectedObjects, which I will have to pass an array of one object to. Even if you didn't get the error, this approach wouldn't work. The selectedObject must be an exact object from the content collection. - selection returns a proxy object. You might try barking up using selectedValue instead. But then, you might still have the binding error, or it might go away since you are binding through selection. Anyway, have you verified that the ArrayController variable is what you expect it to be at the point that bind: is called? HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ 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 live resizing glitch
Please do log bugs when you run into these issues. I did back in August 2005: rdar://problem/4226145. It's still open but I haven't seen it recently so it might have been fixed in Leopard. Thanks! I had looked at your bug quite a few times (I promptly replied replies to the bug logged back on 8/22/05), but I have been unable to make the problem happen. I'll work with you off-list to figure it out. -corbin ___ 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: NSTextFieldCell text color issue in NSTableView with source list highlighting
A quick side note on this problem (which I have confirmed is a bug): - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id) aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger) rowIndex { // note that when the NSTableView Highlight mode is set to source list // setting the text color of NSTextFieldCell seems to misbehave. if ([aCell isKindOfClass:[NSTextFieldCell class]]) { if ([aCell isHighlighted]) { Instead of doing [aCell isHighlighted], I recommend checking the background style, ie: [cell backgroundStyle] == NSBackgroundStyleDark (etc..). This is what I was trying to say in the old post: http://www.cocoabuilder.com/archive/message/cocoa/2008/11/5/222008 But, even with that considered, the problem still happens with source list tables. --corbin [aCell setTextColor: [NSColor lightGrayColor]]; } else { [aCell setTextColor: [NSColor darkGrayColor]]; } } } Has anyone else encountered this? Work around solution is probably to use NSAttributedString. Jonathan Mitchell Central Conscious Unit http://www.mugginsoft.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Performance problem with GC enabled
On Fri, Mar 13, 2009 at 12:04 PM, Paul Sanders p.sand...@dsl.pipex.com wrote: (Off topic again): Call me old-fashioned, but I don't like autorelease pools all that much. I believe Cocoa could have gotten along just fine without them, had they never been invented. I prefer C++-style 'smart pointers' that delete (or release) themselves when they go out of scope. That way you avoid the loss of determinism and potential memory usage peaks that autorelease pools introduce and it's really not painful writing code that way. It's a pity that Objective-C doesn't support such a construct - life would have been so much easier. But it's far too late now. Autorelease pools exist explicitly for passing things out of scopes (return [retval autorelease];), otherwise you have to deal with substantially more complicated ownership semantics for all methods that return objects. The fact that people have overloaded them to emulate scoped release a has more to do with people not wanting to have to cleanup after themselves and the autorelease infrastructure already existing. Now, having said that, I don't tend to use autoreleased objects inside a scope they won't escape because I would rather not bloat my apps high watermark and fragment my zones. Instead, I do something along these lines: #define autoscoped __attribute__((cleanup(releaseObject))) static inline void releaseObject(id *object) { [*object release]; } - (void) demo { autoscoped NSArray *myArray = [[NSArray alloc] init]; //do some stuff } The autoscoped macro tags the lval with an attribute that causes the cleanup function to be called when the lvals scope disappears. It is not quite the same as a smart pointer, but it does allow me to have objects automatically released when their scope disappears, without causing autorelease traffic. Louis ___ 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: Performance problem with GC enabled
#define autoscoped __attribute__((cleanup(releaseObject))) static inline void releaseObject(id *object) { [*object release]; } - (void) demo { autoscoped NSArray *myArray = [[NSArray alloc] init]; //do some stuff } The autoscoped macro tags the lval with an attribute that causes the cleanup function to be called when the lvals scope disappears. It is not quite the same as a smart pointer, but it does allow me to have objects automatically released when their scope disappears, without causing autorelease traffic. That's very interesting, I didn't know that attribute existed. I imagine that post-dates autorelease pools by some years. But most objects returned by framework functions are autoreleased which means you can only get rid of them by bracketing them with an autorelease pool. This bugs me somewhat and is obviously less efficient than just throwing them away when you are done with them. But it does let you pass @string as a function parameter I suppose without having to release it afterwards. Still can't say I like it much. Sorry if I hijacked the thread. ___ 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: NSTextFieldCell text color issue in NSTableView with source list highlighting
A followup on this particular problem that Jonathan reported for people to reference: On Mar 12, 2009, at 3:51 AM, jonat...@mugginsoft.com wrote: NSTableViewSelectionHighlightStyleSourceList. The source list style attempts to add auto-formatting to the cell by setting the attributed string for you, if you give it a plain string. This is how the text automatically becomes bold. However, once the attributed string has been created, it will use the settings already set on the cell to format the value. -willDisplayCell: is the last thing that is called in -preparedCellAtColumn:row:, allowing the developer to change anything that the tableview automatically set. - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id) aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger) rowIndex { // note that when the NSTableView Highlight mode is set to source list // setting the text color of NSTextFieldCell seems to misbehave. if ([aCell isKindOfClass:[NSTextFieldCell class]]) { if ([aCell isHighlighted]) { Instead of using -isHighlighted, a more appropriate check would be: if ([aCell backgroundStyle] == NSBackgroundStyleDark || [aCell backgroundStyle] == NSBackgroundStyleLowered) { [aCell setTextColor: [NSColor lightGrayColor]]; } else { [aCell setTextColor: [NSColor darkGrayColor]]; } Based on my above information, one can work around the issue by letting the cell reformat its value. This looses the custom bold attributes applied, but fixes the problem and is a work around: [aCell setStringValue:[aCell stringValue]]; } } Alternatively, you could hook into the process earlier. The earliest point is -tableView:dataCellForTableColumn:row:. You could solve this type of issue with the following code: - (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn: (NSTableColumn *)tableColumn row:(NSInteger)row { NSTextFieldCell *result = (NSTextFieldCell *)[tableColumn dataCell]; if ([[tableView selectedRowIndexes] containsIndex:row]) { // This ignores the fact that we use different colors in a table that has the first responder status [result setTextColor: [NSColor blueColor]]; } else { [result setTextColor: [NSColor yellowColor]]; } return result; } Either solution is perfectly acceptable, and we'll increase our documentation to help developers understand the process of displaying cells. corbin ___ 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: Performance problem with GC enabled
On Fri, Mar 13, 2009 at 1:30 PM, Paul Sanders p.sand...@dsl.pipex.com wrote: That's very interesting, I didn't know that attribute existed. I imagine that post-dates autorelease pools by some years. It's a relatively new GCC-ism. But most objects returned by framework functions are autoreleased which means you can only get rid of them by bracketing them with an autorelease pool. If you're using NSApplication, you already have an autorelease pool. If you need it cleared more frequently, then yes it's your problem to create a new one. This bugs me somewhat and is obviously less efficient than just throwing them away when you are done with them. No, it's not. Without any sort of management, you'd leak memory like crazy in situations where neither the caller or the callee can release the object. But it does let you pass @string as a function parameter I suppose without having to release it afterwards. @ strings are baked into your binary as instances of NSConcreteString. They are not autoreleased. Still can't say I like it much. Well at this point, the only useful advice anyone can offer you is Deal With It. Academic discussion on the merits of autorelease pools unfortunately won't help your project. --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: NSTextFieldCell text color issue in NSTableView with source list highlighting
On Fri, Mar 13, 2009 at 1:34 PM, Corbin Dunn corb...@apple.com wrote: Either solution is perfectly acceptable, and we'll increase our documentation to help developers understand the process of displaying cells. How about instead of changing the object value to an attributed string the framework instead changes the attributes of the cell? Or if NSTableView is going to go to lengths to substitute a bold attributed string in place of my plain string, why can't it also uppercase my strings when they are group rows in a source-list highlighting style? --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: NSTextFieldCell text color issue in NSTableView with source list highlighting
On Mar 13, 2009, at 10:43 AM, Kyle Sluder wrote: On Fri, Mar 13, 2009 at 1:34 PM, Corbin Dunn corb...@apple.com wrote: Either solution is perfectly acceptable, and we'll increase our documentation to help developers understand the process of displaying cells. How about instead of changing the object value to an attributed string the framework instead changes the attributes of the cell? This is a possibility, however, you may notice there is no way to just make a generic NSCell 'bold'. The only way to do this is with an NSAttributedString, which is why this route was chosen. Ultimately, the -willDisplayCell: method is the ideal last place that a developer can change anything they want about the cell using a delegate method. Or if NSTableView is going to go to lengths to substitute a bold attributed string in place of my plain string, why can't it also uppercase my strings when they are group rows in a source-list highlighting style? That's a good point, and it is something we did consider. However, also consider strings may be localized, and that localizations may have specific or different ways of doing capitalization. So, instead of dealing with the possibility of getting it wrong, we simply just provide the correct formatting attributes. For the group row case in source lists, we will bold the font, and apply a special color based on the window key state. As usual, if you feel there are things we could do to improve the frameworks, please do log bugs. We read them all and do make changes based on feedback. corbin ___ 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: Performance problem with GC enabled
Without any sort of management, you'd leak memory like crazy in situations where neither the caller or the callee can release the object. A scheme where it is always the caller's job to release any object returned to it is perfectly viable, as any number of other computing platforms (such as COM on Windows) will testify. The callee simply has to retain the object before it returns it (and autorelease pools would not exist - hooray!). Cocoa is one of a kind in this regard, as far as I know. Anyway, I don't want to harp on. As you say, one has to live with it. I just happen to think it was a mistake. Seductive but dangerous. ___ 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: Singleton Help ...
On Fri, Mar 13, 2009 at 3:51 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote: By definition, if it's a singleton, it will exist for the lifetime of the program; there is no risk of the notification centre sending messages to a now non-existent object. As a smallish nit... singleton nominally implies that only one instance of the singleton class will exist at runtime (for some module boundary) and not that it will and must exist for the life of application. ...of course fairly often singletons do end up with process long life times. In my opinion singletons should normally be written to only exist as long as a client exists or as long as needed to maintain state across the existence of clients or to avoid instantiation related performance issue, etc.. I try to always write them with proper memory management (and unit test them that way) even if they end up living for the life of the application just to make it easier to change its life time in the future (code likes to evolve) without having worry about auditing the memory management it does. So in this particular situation this singleton could be told to go away by the app delegate as one of the last things it does ... of course application termination is going to reap all of these objects so you likely don't need to do anything. -Shawn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding to selection of NSArrayController manually
On Mar 13, 2009, at 9:42 AM, Ivy Feraco wrote: I have an NSArrayController subclass and an NSPopUpButton subclass. I am trying to bind the NSPopUpButton's selected object to the selection of my array controller. I have to do this manually for reasons I won't get into here. But when I do this (self is myPopUpButton) [self bind:@selectedObject toObject:ArrayController withKeyPath:@selection options:nil]; I get the error that my array controller is not KVC for the key path selection. selection is definitely a controller key option in Interface Builder, is it possible that this doesn't work programmatically? Has anyone else run into this problem??? I want to bind to the selected object, not the index... so it seems my only option here is selectedObjects, which I will have to pass an array of one object to. I'm no expert in this area, but have dabbled with some code related to this, hence I offer the following subject to proviso... I believe the only KVObservable properties of NSArrayController that you can use in this way are: -selectedObjects, -selectionIndex, and - sectionIndexes. My suggestion, as you have subclassed NSArrayController, would be to add an additional KVO compliant property that returns the underlying (first) selected object (not the proxy object). Implement a - selectedObject property in your sub class and use it as the keyPath in the bind statement. - (id) selectedObject { return [[self selectedObjects] objectAtIndex:0]; } HTH. ___ 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: Binding to selection of NSArrayController manually
Yes thanks I did something like this. I realize now that selection is just a getter method on NSObjectController so no sense binding to it without a keypath. Ivy Feraco UI Developer i...@boxstudios.com On Mar 13, 2009, at 2:34 PM, Stuart Malin wrote: On Mar 13, 2009, at 9:42 AM, Ivy Feraco wrote: I have an NSArrayController subclass and an NSPopUpButton subclass. I am trying to bind the NSPopUpButton's selected object to the selection of my array controller. I have to do this manually for reasons I won't get into here. But when I do this (self is myPopUpButton) [self bind:@selectedObject toObject:ArrayController withKeyPath:@selection options:nil]; I get the error that my array controller is not KVC for the key path selection. selection is definitely a controller key option in Interface Builder, is it possible that this doesn't work programmatically? Has anyone else run into this problem??? I want to bind to the selected object, not the index... so it seems my only option here is selectedObjects, which I will have to pass an array of one object to. I'm no expert in this area, but have dabbled with some code related to this, hence I offer the following subject to proviso... I believe the only KVObservable properties of NSArrayController that you can use in this way are: -selectedObjects, -selectionIndex, and - sectionIndexes. My suggestion, as you have subclassed NSArrayController, would be to add an additional KVO compliant property that returns the underlying (first) selected object (not the proxy object). Implement a - selectedObject property in your sub class and use it as the keyPath in the bind statement. - (id) selectedObject { return [[self selectedObjects] objectAtIndex:0]; } HTH. ___ 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: TXT Records with NSImages
That's what I thought too. But how do you use the NULL record? Joe On Mar 13, 2009, at 7:36 AM, Keith Duncan wrote: Joe, That's a lot of data to be storing in the TXT record. I'd advise that you store it in the NULL record as iChat does for 'Bonjour' chat. Keith ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Handling errors in -initWithCoder:
On 3/13/09 3:05 PM, Graham Cox said: One of my classes can sometimes fail in -initWithCoder: - it relies on certain resources being available and if it doesn't get them, I thought I could follow the same pattern as -init and autorelease self and return nil. Actually, I don't think that's the right pattern for failure in init. You should call [super dealloc] not [self autorelease]. See: http://lists.apple.com/archives/objc-language/2008/Sep/msg00133.html -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ 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: NSManagedObject validateForDelete problem
On 2009 Mar 13, at 01:44, Ben Trumbull wrote: -validateForDelete: is ... not intended to double as -canDelete or - isDeleteable. When I first started using Core Data I had the mistaken impression that the various -[NSManagedObject validate] methods were hooks into which I could place my validation code or business logic, and things would just work. But after playing with it for awhile, all I was able to get was sheets dropping over my document windows when I tried to save, saying stuff like The document could not be saved. Multiple validation errors occurred. I didn't think my users would appreciate those sheets any more than I did :O So, instead I do all my validation and model adjustments elsewhere, in custom setters or in response to notifications. I don't believe that the -[NSManagedObject validate] methods have much use to the application programmer. ___ 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 color management?
When we put PNG resources in our iPhone apps, what color space are they displayed under? I know PNGs are re-processed by Xcode (into illegal, but more- efficient, iPhone PNGs), are the color profiles embedded in PNGs used either at the re-processing time or at the time of drawing? As far as I can tell there isn't support for multiple color spaces on the iPhone - is there color management at all? What color space should we be targeting in our graphics if there's no color management? sRGB, 2.2 gamma? Apple Generic, 1.8? Beuller? Anyone? Thanks, -Wil ___ 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: setDataSource
On Mar 13, 2009, at 3:14 PM, David Blanton wrote: Is it true that reloadData is synchronous while setDataSource (which makes a reload happen) is asynchronous ? What class are you referring to? NSTableView? All are synchronous, none are asynchronous. Tiling/redrawing is all lazily done. corbin ___ 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
NSProgressIndicator's setUsesThreadedAnimation only works sometimes?
Hi all, I'm trying to make a cheap, modal, indeterminate progress dialog, but I'm having trouble animating the progress bar. (Yes, I know this is only slightly better than the spinning wheel of death. Yes, I know I should thread my long running code. Yes, I know I should not block the main thread. One day...) The docs for NSProgressIndicator's setUsesThreadedAnimation say This value is only a hint and may be ignored. Indeed, sometimes it animates and sometimes it does not. I can't find any pattern. Is there a way to reliably make an NSProgressIndicator animate while the main thread is blocked? Thanks, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ 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: NSProgressIndicator's setUsesThreadedAnimation only works sometimes?
No, none at all. The main AppKit thread is the thread that will be repainting your progress bar. If it's blocked, it can't paint the new state of your progress bar. Rob On Mar 13, 2009, at 3:20 PM, Sean McBride wrote: Hi all, I'm trying to make a cheap, modal, indeterminate progress dialog, but I'm having trouble animating the progress bar. (Yes, I know this is only slightly better than the spinning wheel of death. Yes, I know I should thread my long running code. Yes, I know I should not block the main thread. One day...) The docs for NSProgressIndicator's setUsesThreadedAnimation say This value is only a hint and may be ignored. Indeed, sometimes it animates and sometimes it does not. I can't find any pattern. Is there a way to reliably make an NSProgressIndicator animate while the main thread is blocked? Thanks, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ 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/rob.ross%40gmail.com This email sent to rob.r...@gmail.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: NSProgressIndicator's setUsesThreadedAnimation only works sometimes?
Rob, Thanks for your reply. But what you say can't be so. As I said, sometimes my 'hint' is accepted and the progress bar animates, and I am definitely blocking the main thread with my own code at the same time. But it only works sometimes, and I'm looking to make it work all the time. But the docs are not encouraging. On 3/13/09 3:25 PM, Rob Ross said: No, none at all. The main AppKit thread is the thread that will be repainting your progress bar. If it's blocked, it can't paint the new state of your progress bar. Rob On Mar 13, 2009, at 3:20 PM, Sean McBride wrote: Hi all, I'm trying to make a cheap, modal, indeterminate progress dialog, but I'm having trouble animating the progress bar. (Yes, I know this is only slightly better than the spinning wheel of death. Yes, I know I should thread my long running code. Yes, I know I should not block the main thread. One day...) The docs for NSProgressIndicator's setUsesThreadedAnimation say This value is only a hint and may be ignored. Indeed, sometimes it animates and sometimes it does not. I can't find any pattern. Is there a way to reliably make an NSProgressIndicator animate while the main thread is blocked? Thanks, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ 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/rob.ross%40gmail.com This email sent to rob.r...@gmail.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: NSProgressIndicator's setUsesThreadedAnimation only works sometimes?
Your question was if there was a reliable way of doing it, and as you have experienced, that's the best you can hope to achieve without using a separate thread. Rob On Mar 13, 2009, at 3:29 PM, Sean McBride wrote: Rob, Thanks for your reply. But what you say can't be so. As I said, sometimes my 'hint' is accepted and the progress bar animates, and I am definitely blocking the main thread with my own code at the same time. But it only works sometimes, and I'm looking to make it work all the time. But the docs are not encouraging. On 3/13/09 3:25 PM, Rob Ross said: No, none at all. The main AppKit thread is the thread that will be repainting your progress bar. If it's blocked, it can't paint the new state of your progress bar. Rob On Mar 13, 2009, at 3:20 PM, Sean McBride wrote: Hi all, I'm trying to make a cheap, modal, indeterminate progress dialog, but I'm having trouble animating the progress bar. (Yes, I know this is only slightly better than the spinning wheel of death. Yes, I know I should thread my long running code. Yes, I know I should not block the main thread. One day...) The docs for NSProgressIndicator's setUsesThreadedAnimation say This value is only a hint and may be ignored. Indeed, sometimes it animates and sometimes it does not. I can't find any pattern. Is there a way to reliably make an NSProgressIndicator animate while the main thread is blocked? Thanks, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ 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/rob.ross %40gmail.com This email sent to rob.r...@gmail.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: NSProgressIndicator's setUsesThreadedAnimation only works sometimes?
Sean, AppKit is using -[NSApplication updateWindows] for some of animation thread synchronization tasks. If you experience animation not properly starting up with blocking operations, you can kick start the animation by calling the method before going into the operation. Aki Rob, Thanks for your reply. But what you say can't be so. As I said, sometimes my 'hint' is accepted and the progress bar animates, and I am definitely blocking the main thread with my own code at the same time. But it only works sometimes, and I'm looking to make it work all the time. But the docs are not encouraging. On 3/13/09 3:25 PM, Rob Ross said: No, none at all. The main AppKit thread is the thread that will be repainting your progress bar. If it's blocked, it can't paint the new state of your progress bar. Rob On Mar 13, 2009, at 3:20 PM, Sean McBride wrote: Hi all, I'm trying to make a cheap, modal, indeterminate progress dialog, but I'm having trouble animating the progress bar. (Yes, I know this is only slightly better than the spinning wheel of death. Yes, I know I should thread my long running code. Yes, I know I should not block the main thread. One day...) The docs for NSProgressIndicator's setUsesThreadedAnimation say This value is only a hint and may be ignored. Indeed, sometimes it animates and sometimes it does not. I can't find any pattern. Is there a way to reliably make an NSProgressIndicator animate while the main thread is blocked? Thanks, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montr.ANial, QuNibec, Canada ___ 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/rob.ross %40gmail.com This email sent to rob.r...@gmail.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/aki%40apple.com This email sent to a...@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
Using NSPersistentDocument without NSApp. OK?
I've working on a background helper, created Xcode as a Foundation tool. It can open, edit and save Core Data NSPersistentDocuments created by my main app. It seems to work. I know from the Core Data Utility Tutorial (formerly called Low Level) that Core Data without NSApp is OK. What about NSPersistentDocument without NSApp? If anyone knows any show-stopping dependency that I might discover around shipping time, please tell us about it. Thanks, Jerry ___ 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: Performance problem with GC enabled
On Thu, Mar 12, 2009 at 3:17 PM, Peter Ammon pam...@apple.com wrote: Hi John, Instead of storing each string individually into the heap, try batching up, say, 1k or so into a stack allocated buffer. Then use objc_memmove_collectable() to move them in bulk into the heap at the point your stack allocated buffer gets full, or your scan finishes. I actually did give this a shot, or something close to it. I tried using just the stack (swapping NSAllocateCollectable() with alloca()), but no joy- exactly the same times came out. Good call though. The problem is objc_assign_strongCast(), which surprisingly doesn't seem to have a 'fast path' escape if it detects a write to an address on the stack. I would have figured that at least the main threads stack bounds would have been accounted for (I would be surprised if this wasn't immutable once the linker handed off execution to the program), as this really amounts to nothing more than a = = check, but nope. ___ 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
sending rich text emails using Scripting Bridge and Mail
I have downloaded the Cocoa example which uses Scripting Bridge to send emails. I wanted to know is it possible to use that system to send rich text emails. That is, is there a way to get the Mail App to recognize AttributedString instead of just plain string. Thanks in advance Reza ___ 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: UIPickerView Caching Items
To everyone that has read this post - I am a stupid programmer and there is no caching. I wasn't changing my service object with the new name! Useless - my apologies!! Eggsy _ All your Twitter and other social updates in one place http://clk.atdmt.com/UKM/go/137984870/direct/01/___ 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: EXC_BAD_ACCESS on NSImageView::setImage
On Wed, Mar 11, 2009 at 9:33 AM, Scott Ribe scott_r...@killerbytes.com wrote: Does your setImage method retain the image? The object ExternalView is a NSImageView so the setImage is the one of NSImageView. The doc says nothing about it, but i added some debug log like this : NSLog(@BEFORE : %d, [NewDisplayImage retainCount]); [CameraView setImage:NewDisplayImage]; NSLog(@AFTER : %d, [NewDisplayImage retainCount]); 2009-03-13 17:17:35.105 xxx[2281:e503] BEFORE : 1 2009-03-13 17:17:35.106 xxx[2281:e503] AFTER : 3 So i guess the image have been retained 2 times -- I. ___ 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: Performance problem with GC enabled
On Mar 13, 2009, at 4:47 PM, John Engelhart wrote: On Thu, Mar 12, 2009 at 3:17 PM, Peter Ammon pam...@apple.com wrote: Hi John, Instead of storing each string individually into the heap, try batching up, say, 1k or so into a stack allocated buffer. Then use objc_memmove_collectable() to move them in bulk into the heap at the point your stack allocated buffer gets full, or your scan finishes. I actually did give this a shot, or something close to it. I tried using just the stack (swapping NSAllocateCollectable() with alloca()), but no joy- exactly the same times came out. Good call though. That wasn't quite my suggestion, and I would not expect that to result in any improvement. If you store an object through an arbitrary pointer, the compiler will use a write barrier. I doubt the compiler will figure out that because the memory came from alloca(), it is on the stack. The goal is for the compiler to not use individual write barriers at all, and it won't for stack allocated buffers. So my suggestion is to make a buffer that the compiler knows is on the stack: id stackBuffer[1024]; Stores to that buffer will not go through write barriers. When that buffer is full, use objc_memmove_collectable() to move it to the heap. I wrote a quick test to try this and it resulted in a 10x speedup compared to individual write barriers. -Peter ___ 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: TXT Records with NSImages
Joe, You'll need to drop below NSNetService and CFNetService to manipulate the NULL record data. Take a look at the API in dns_sd.h for the functions you need. Like a TXT record, a NULL record has a limit of 65535 bytes but unlike the TXT record it isn't segmented. Here's some sample code (from an iPhone application) to get you started: if (ABPersonHasImageData(self.personRecord)) { NSData *rawAvatarData = (id)ABPersonCopyImageData(self.personRecord); UIImage *avatarImage = [UIImage imageWithData:rawAvatarData]; NSData *avatarData = UIImageJPEGRepresentation(avatarImage, 0); unsigned char hash[CC_SHA1_DIGEST_LENGTH]; CC_SHA1([avatarData bytes], [avatarData length], hash); NSMutableString *hashString = [NSMutableString stringWithCapacity: (CC_SHA1_DIGEST_LENGTH * 2)]; for (int i = 0; i CC_SHA1_DIGEST_LENGTH; i++) [hashString appendFormat:@%02x, (unsigned long)hash[i], nil]; [self.TXTProperties setObject:hashString forKey:@phsh]; if (avatarRecord == NULL) { error = DNSServiceAddRecord(_service, avatarRecord, 0, kDNSServiceType_NULL, [avatarData length], [avatarData bytes], 0); } else { error = DNSServiceUpdateRecord(_service, avatarRecord, 0, [avatarData length], [avatarData bytes], 0); } } else { error = DNSServiceRemoveRecord(_service, avatarRecord, 0); avatarRecord = NULL; [self.TXTProperties removeObjectForKey:@phsh]; } Keith ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Performance problem with GC enabled
On Fri, Mar 13, 2009 at 5:28 AM, Paul Sanders p.sand...@dsl.pipex.com wrote: Bill said something in passing on this issue which I think is important. To paraphrase: If you care about performance, don't use the Cocoa RegEx stuff to parse large amounts of data. I disagree :), and I have numbers to back it up: (RegexKitLite was used to do the regex processing in the examples below) [subjectString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] [subjectString componentsSeparatedByRegex:[NSString stringWithUTF8String:(?:\\r\n|[\n\\v\\f\\r\302\205\\p{Zl}\\p{Zp}\\t ])]] componentsSeparatedByCharactersInSet: Time used: 4114134.0, per: 1.493509760680, count: 2754675 componentsSeparatedByRegex: Time used: 1577230.0, per: 0.572564821621, count: 2754675 In this case, regexes beat the system method by: 4114134.0 / 1577230.0 = 2.60. --- [subjectString componentsSeparatedByString:@\n] [subjectString componentsSeparatedByRegex:[NSString stringWithUTF8String:(?:\\r\n|[\n\\v\\f\\r\302\205\\p{Zl}\\p{Zp}])]] componentsSeparatedByString: Time used: 548741.0, per: 2.181959521253, count: 251490 componentsSeparatedByRegex: Time used: 320646.0, per: 1.274985088870, count: 251490 In this case, regexes beat the system method by: 548741.0 / 320646.0 = 1.71. I think this observation is true whether you use GC or not. GC just makes it worse. I'd like to see a pure-C benchmark of the original test, perhaps just from the command line using egrep. I suspect the results would be startling. How about perl instead? (I don't think egrep is a fair test, it doesn't have to 'do anything' with the results, like create a new string from them). This is a rough perl equivalent of my original problem: $text = ; $cnt = 0; while() { $text .= $_; } for($loops = 0; $loops 1; $loops++) { my @results; while($text =~ /\S+/g) { push(@results, $1); $cnt++; } } shell% time /usr/bin/perl pl_rkl.pl BIG.txt 2.159u 0.030s 0:02.22 98.1% 0+0k 0+0io 0pf+0w shell% time rkl_tests 1.874u 0.073s 0:01.97 98.4% 0+0k 0+0io 0pf+0w Now, the perl example could be improved (notably the part that sucks in the text), but I think it's fair to say that this isn't quite the result you'd intuitively expect. Naturally, these results aren't representitive of every use case, but I think it goes to show that processing strings in Cocoa with regexes can be competitive with other solutions out there. Having said all of which, I think the original test is not unfair and I agree with a lot of the points people have made in support of that view. It's always painful to have to step outside the Cocoa frameworks, and (off topic) it seems that GC can make it more so. I for one will not be using it. ___ 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: kvc/kvo for arrays defeated me.
On Mar 13, 2009, at 15:34, Darren Minifie wrote: === Interface file: === @interface PerceptionController : NSWindowController { NSMutableArray* dpcm2; } @property(nonatomic, retain) NSMutableArray* dpcm2; -(void)insertObject:(id)num inDpcm2AtIndex:(unsigned)index; -(void)removeObjectFromDpcm2AtIndex:(unsigned)index; -(void)replaceObjectInDpcm2AtIndex:(unsigned)index withObject:(id)num; === implementation file === @synthesize dpcm2; -(id)init{ self = [super initWithWindowNibName:@perceptionPanel]; self.dpcm2 = [NSMutableArray arrayWithCapacity:6]; for(int i = 0; i6; i++){ // just adding eight 0's to the array [dpcm2 addObject:[NSNumber numberWithInt:0]]; } return self; } -(void)insertObject:(id)num inDpcm2AtIndex:(unsigned)index{ [[self dpcm2] insertObject:num atIndex:index]; } -(void)removeObjectFromDpcm2AtIndex:(unsigned)index{ [[self dpcm2] removeObjectAtIndex:index]; } -(void)replaceObjectInDpcm2AtIndex:(unsigned)index withObject: (id)num{ [[self dpcm2] replaceObjectAtIndex:index withObject:num]; } == end code == within interface builder, I have a table column bound to the arrangedObjects property of an array controller. The array controller is bound to the dpcm2 array. Again, the getters are working, but setters arent. One resource I found says this: For best performance, you should implement the two KVC-compliant methods shown in the next listing, instead of the setShapes: method:. (its in: Sample KVC-Compliant Accessor Methods apple docs). I dont understand why they dont implement the setter for their property, and this may be the cause of my problem. Without the setter method how do you ever assign something to the property in the first place? The runtime error i receive when trying to change a value is: 2009-03-13 15:33:36.142 a4[4494:10b] Error setting value for key path of object 0 (from bound object NSTableColumn: 0x187150(null)): [NSCFNumber 0x1105d0 setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key . The problem here is that your table column must be bound to a property of the class of the objects in the array. (That is, you specified 'arrangedObjects' for the controller key path of the column binding, but you specified nothing for the model key path.) These objects, according to your code, are of class NSNumber, which (a) have no properties useful to you here and (b) are immutable anyway, so can't be edited. Here's how it's supposed to work: Typically, an array property like this is best named with a *plural* noun. So, your methods will be called insertObject:inMySomethingsAtIndex, removeObjectFromMySomethingsAtIndex. Then, you create a class called MySomething (singular) that has the properties you need for your table columns. In this case, maybe you just have one table column, so the property of MySomething might be called 'dpcm2' (with values that are NSNumber objects, or of some scalar numeric type, according to your needs). Then you bind your NSArrayController to File's Owner, model key path MySomethings. You bind your table column to the controller, controller key path arrangedObjects, model key path dpcm2. When your table column displays a specific row, it retrieves the MySomething object corresponding to the row (getting it from arrangedObjects using the rowIndex), asks the object for its dpcm2 property, and displays that value. When you edit a specific row of your table column, the value you type in is set as the new value of the corresponding MySomething object. If your dpcm2 property is a scalar, the typed value (actually a string to begin with) is automatically converted to a number. If your dpcm2 property is a NSNumber, you must use a numeric formatter on the cell in the table column to force the conversion to NSNumber, otherwise the new value will be set as a NSString (which probably isn't what you want). The reason it currently works for getting the values is that an empty model key path is interpreted as self. Thus each row in the table is being evaluated as [NSNumber self] which is the number object itself, which is something the column can display. However, it's never possible to *change* an object via its self method (and, as I said, NSNumber objects aren't mutable anyway). ___ 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
Releasing objects in Scripting Bridge
Exploring the example of sending emails using Scripting Bridge, I see that objects are allocated but not released: MailOutgoingMessage *emailMessage = [[[mail classForScriptingClass:@outgoing message] alloc] initWithProperties: [NSDictionary dictionaryWithObjectsAndKeys:@testing sending mail, @subject,messageString, @content, nil]]; this is where the object is created with an alloc, but it is not released later. This also occurs in other parts of the code. Is this a mistake or is this not necessary when calling through to the scripts to other applications. Thanks again Reza ___ 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: kvc/kvo for arrays defeated me.
On Fri, Mar 13, 2009 at 9:00 PM, Quincey Morris quinceymor...@earthlink.net wrote: The problem here is that your table column must be bound to a property of the class of the objects in the array. (That is, you specified 'arrangedObjects' for the controller key path of the column binding, but you specified nothing for the model key path.) This is the binding that's used to populate the object value of the column's cell. You should still bind the table's content binding so that the selection is taken care of. --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: kvc/kvo for arrays defeated me.
On Mar 13, 2009, at 18:00, Quincey Morris wrote: When you edit a specific row of your table column, the value you type in is set as the new value of the corresponding MySomething object. Oops, that should read: ... as the new value of the corresponding MySomething object property. ___ 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
NSTask and setuid
Hi All, I'm developing a setuid tool for my application and seems that NSTask doesn't respect the setuid bit and the effective uid remains 501. However when launching the tool from the terminal the effective uid is 0 as expected. What am i missing? Mudi ___ 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: kvc/kvo for arrays defeated me.
On Mar 13, 2009, at 18:20, Kyle Sluder wrote: On Fri, Mar 13, 2009 at 9:00 PM, Quincey Morris quinceymor...@earthlink.net wrote: The problem here is that your table column must be bound to a property of the class of the objects in the array. (That is, you specified 'arrangedObjects' for the controller key path of the column binding, but you specified nothing for the model key path.) This is the binding that's used to populate the object value of the column's cell. You should still bind the table's content binding so that the selection is taken care of. In the simplest (and commonest) case, you don't have to bind the table to anything because it internally figures out the content binding from the column bindings, though of course there's nothing wrong with binding it explicitly too. Similarly you can omit the selectionIndexes and sortDescriptors binding unless you need something other than the default behavior. Or am I missing your point? ___ 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: kvc/kvo for arrays defeated me.
On Fri, Mar 13, 2009 at 9:36 PM, Quincey Morris quinceymor...@earthlink.net wrote: Or am I missing your point? No, you're not. I always bind it explicitly because I know I'll forget if my column bindings aren't all bound to keypaths off the same controller property. It's also not documented that the table view automagically configures the selection bindings. --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: kvc/kvo for arrays defeated me.
thank you guys so much! That makes perfect sense (now), and I'm glad I only wasted most of the day. I do think that programming guide on bindings could be improved or elaborated on a little bit. Kyle what do you mean by binding the table view's content property? I understand what you mean, but I'm unsure of what I should bind it to. The array controller's array? or the tableView's dataSource? On Fri, Mar 13, 2009 at 6:40 PM, Kyle Sluder kyle.slu...@gmail.com wrote: On Fri, Mar 13, 2009 at 9:36 PM, Quincey Morris quinceymor...@earthlink.net wrote: Or am I missing your point? No, you're not. I always bind it explicitly because I know I'll forget if my column bindings aren't all bound to keypaths off the same controller property. It's also not documented that the table view automagically configures the selection bindings. --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/minofifa%40gmail.com This email sent to minof...@gmail.com -- Darren Minifie Graduate Studies: Computer Science www.myavalon.ca www.ohsnapmusic.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: Performance problem with GC enabled
On Fri, Mar 13, 2009 at 4:38 AM, Marcel Weiher marcel.wei...@gmail.com wrote: On Mar 12, 2009, at 10:54 AM, Bill Bumgarner wrote: In the context of an application, such processing is likely to be on a secondary thread and there is likely to be synchronization of data between threads. The overhead of the write barrier (which is spin lock contention under the covers, most likely) will be somewhat offset by the vast decrease in the cost of moving objects between threads, for example. The synchronization overhead for moving progress updates across threads every 10th of a second is negligible unless you're doing something very very wrong. I have to agree with Marcel on this. In fact, in such a scenario, I'm almost certainly going to be using OSAtomicEnqueue and OSAtomicDequeue. I'm willing to guarantee that this will outperform a call to objc_assign_strongCast by several orders of magnitude, so much so that it would actually be an incentive to turn off GC. It has the added advantage of never causing the background worker threads to block while waiting for a spin lock. Come to think of it, I'm not even sure how you could write a GC enabled multi-threaded app that uses one thread per CPU to split work up. All your background threads are going to come to a grinding halt as they serialize inside objc_assign_strongCast. Sure -- and if I were writing a Cocoa application to do exactly that, it would be doing all kinds of UI updates during the process to keep the user up to date on progress, give them a feel for whether the analysis is moving along in the correct direction, etc,etc,etc and all of that graphics related chatter is very likely going to far outweigh the CPU cycles consumed by the actual data processing bit. Not if you're doing it right. Again, I have to agree with Marcel on this. In fact I'd say, as a rough rule of thumb, if shark is telling you that you're spending more than 5% of your time doing UI updates, you're doing something wrong. If you have something that takes 5 minutes to process without any kind of UI updates, and your GUI versions interface updates now 'far outweigh the CPU cycles consumed' (50%) relative to the data processing, you've now turned something that takes 5 minutes in to 10+ minutes. I can't say I understand why you think this is reasonable, or even the norm. ___ 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
Calling Script Objects in Applescript
We have a lot of code in libraries in Applescript. Now starting to look at using Cocoa to move forward, as we are really using Applescript to pretty much its limit. But it is not a short term solution to rewrite all our Applescript libraries in Objective-C. We need to be able to use Objective-C programs to load and execute our Applescripts. I've managed to get a program to execute an Applescript and to execute a handler in an Applescript. But most of our libraries are saved as Script Objects. Please could someone point me in the right direction for executing a subroutine inside a script object in an Applescript. I'm guessing I could do something like: NSApplescript *scriptObject = [[NSAppleScript alloc] initWithSource: @set scriptObject to (scriptObjectName of (load script file scriptPath)) tell scriptObject to doHandler()]; and execute it, but that seems to be quite klunky. There must be a neater way to do it. Any advice, hints and links will be gratefully received. Thank you Karen ___ 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: kvc/kvo for arrays defeated me.
On Fri, Mar 13, 2009 at 10:04 PM, Darren Minifie minof...@gmail.com wrote: Kyle what do you mean by binding the table view's content property? I understand what you mean, but I'm unsure of what I should bind it to. The array controller's array? or the tableView's dataSource? Well I assume you're not using a data source since you're using bindings. The column bindings are, strictly speaking, used only to provide content for the column's cell when drawing the rows of the table. The table itself, not its columns, manages its selection, so in order to coordinate this selection with the controller its own selection bindings need to be bound to the controller supplying its data. Binding the table's content binding will take care of these bindings automatically. If it can figure it out, the table view will also deduce the object and keypath to use for its content binding from the columns' value bindings. So you would normally have something like this: column1.value - [myController].arrangedObjects.title column2.value - [myController].arrangedObjects.artist Then the framework will automatically fill in the following bindings: tableView.content - [myController].arrangedObjects tableView.selectionIndexes - [myController].selectionIndexes tableView.sortDescriptors - [myController].sortDescriptors You can manually specify these three bindings, which is particularly useful if you need the selection in the table view to be bound to an array controller completely different from the one(s) providing data for your column(s). Also, I see that the NSTableView bindings document has been updated with more information on to automagic bindings: http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSTableView.html Thank you to whoever took care of that one. --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: Performance problem with GC enabled
On Fri, Mar 13, 2009 at 8:26 PM, Peter Ammon pam...@apple.com wrote: On Mar 13, 2009, at 4:47 PM, John Engelhart wrote: On Thu, Mar 12, 2009 at 3:17 PM, Peter Ammon pam...@apple.com wrote: Hi John, Instead of storing each string individually into the heap, try batching up, say, 1k or so into a stack allocated buffer. Then use objc_memmove_collectable() to move them in bulk into the heap at the point your stack allocated buffer gets full, or your scan finishes. I actually did give this a shot, or something close to it. I tried using just the stack (swapping NSAllocateCollectable() with alloca()), but no joy- exactly the same times came out. Good call though. That wasn't quite my suggestion, and I would not expect that to result in any improvement. If you store an object through an arbitrary pointer, the compiler will use a write barrier. I doubt the compiler will figure out that because the memory came from alloca(), it is on the stack. Huh.. I have to say, my first response would have been that the compiler would definitely figure it out, but that's a topic for a different conversation. (it has to do with just how tightly integrated alloca() is to the compiler internals, see http://c-faq.com/malloc/alloca.html for a rough idea why) The goal is for the compiler to not use individual write barriers at all, and it won't for stack allocated buffers. So my suggestion is to make a buffer that the compiler knows is on the stack: id stackBuffer[1024]; Stores to that buffer will not go through write barriers. When that buffer is full, use objc_memmove_collectable() to move it to the heap. I wrote a quick test to try this and it resulted in a 10x speedup compared to individual write barriers. Ok, now I see where you're going. I'll certainly give it a whirl, but it's going to make swiss cheese out of the code with #ifdef __OBJC_GC__ statements, unfortunately. (the code needs to work with or without GC (w/o -fobjc-gc*), and with or without -std=(c|gnu)99 and thus the use of alloca(), not VLAs). Thanks for the suggestion. Hmmm, that does raise the obvious question of Does objc_memmove_collectable() hold the GC lock the entire time it's doing its thing? If so, it'll probably make some sense to find that sweet spot where you hit the point of diminishing returns so you keep the lock for as short a time as possible. ___ 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: NSTask and setuid [SOLVED]
It turned out that I set the setuid bit on different file from the one I launched with NSTask. This took me about 3 hours to realize, sorry :) On Mar 14, 2009, at 2:24 AM, Mudi Dandan wrote: Hi All, I'm developing a setuid tool for my application and seems that NSTask doesn't respect the setuid bit and the effective uid remains 501. However when launching the tool from the terminal the effective uid is 0 as expected. What am i missing? Mudi ___ 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/mudi%40binarynights.com This email sent to m...@binarynights.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: Re: kvc/kvo for arrays defeated me.
Oh ok I understand. Thanks! I have one last question about this stuff. In the attributes panel for an array controller, there is a field called Object Controller Class Name. The tool tip says to set this to the class that will serve to add new objects to the controller's managed array. This more or less makes sense, but I just wanted to be sure. If my array controller was managing an array of Widget objects, would i set this field to Widget? On Mar 13, 2009 7:57pm, Kyle Sluder kyle.slu...@gmail.com wrote: On Fri, Mar 13, 2009 at 10:04 PM, Darren Minifie minof...@gmail.com wrote: Kyle what do you mean by binding the table view's content property? I understand what you mean, but I'm unsure of what I should bind it to. The array controller's array? or the tableView's dataSource? Well I assume you're not using a data source since you're using bindings. The column bindings are, strictly speaking, used only to provide content for the column's cell when drawing the rows of the table. The table itself, not its columns, manages its selection, so in order to coordinate this selection with the controller its own selection bindings need to be bound to the controller supplying its data. Binding the table's content binding will take care of these bindings automatically. If it can figure it out, the table view will also deduce the object and keypath to use for its content binding from the columns' value bindings. So you would normally have something like this: column1.value - [myController].arrangedObjects.title column2.value - [myController].arrangedObjects.artist Then the framework will automatically fill in the following bindings: tableView.content - [myController].arrangedObjects tableView.selectionIndexes - [myController].selectionIndexes tableView.sortDescriptors - [myController].sortDescriptors You can manually specify these three bindings, which is particularly useful if you need the selection in the table view to be bound to an array controller completely different from the one(s) providing data for your column(s). Also, I see that the NSTableView bindings document has been updated with more information on to automagic bindings: http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSTableView.html Thank you to whoever took care of that one. --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: Performance problem with GC enabled
On Mar 13, 2009, at 7:59 PM, John Engelhart wrote: On Fri, Mar 13, 2009 at 8:26 PM, Peter Ammon pam...@apple.com wrote: http://c-faq.com/malloc/alloca.html for a rough idea why) The goal is for the compiler to not use individual write barriers at all, and it won't for stack allocated buffers. So my suggestion is to make a buffer that the compiler knows is on the stack: id stackBuffer[1024]; Stores to that buffer will not go through write barriers. When that buffer is full, use objc_memmove_collectable() to move it to the heap. I wrote a quick test to try this and it resulted in a 10x speedup compared to individual write barriers. Ok, now I see where you're going. I'll certainly give it a whirl, but it's going to make swiss cheese out of the code with #ifdef __OBJC_GC__ statements, unfortunately. (the code needs to work with or without GC (w/o -fobjc-gc*), and with or without -std=(c|gnu)99 and thus the use of alloca(), not VLAs). I think you're saying that it's more convenient for you to work with a pointer than directly with an array. If so, another way you can defeat write barriers is with a cast to void*: void func(id *ptr) { ptr[0] = @foo; // --- write barrier ((void **)ptr)[0] = @bar; // no write barrier } Of course, this is only safe if the pointer points at something not in the GC heap, e.g. on the stack or in malloc()ed memory. If you store into the GC heap this way, your object is likely to be prematurely collected. Thanks for the suggestion. Hmmm, that does raise the obvious question of Does objc_memmove_collectable() hold the GC lock the entire time it's doing its thing? If so, it'll probably make some sense to find that sweet spot where you hit the point of diminishing returns so you keep the lock for as short a time as possible. I believe it does hold the lock the entire time in Leopard. -Peter ___ 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: Performance problem with GC enabled
On Fri, Mar 13, 2009 at 2:03 PM, Paul Sanders p.sand...@dsl.pipex.com wrote: Without any sort of management, you'd leak memory like crazy in situations where neither the caller or the callee can release the object. A scheme where it is always the caller's job to release any object returned to it is perfectly viable, as any number of other computing platforms (such as COM on Windows) will testify. The callee simply has to retain the object before it returns it (and autorelease pools would not exist - hooray!). Cocoa is one of a kind in this regard, as far as I know. No need to look to Windows, OS X's own CoreFoundation has this kind of memory management: manual refcounting, no autorelease. It does indeed work. It's also tremendously verbose. What would be a simple one-liner in Cocoa turns into a sprawling mess of code due to the need to release temporary objects. Worse, it forces the API to expose implementation details. When there's a Get function (one which returns an object you don't own) in CF-land, that means that whatever you're calling necessarily retains a reference to it. If Apple later on wants to change how it works internally so that the function returns a temporary object instead, well, too bad, can't! In Cocoa, the existence of autorelease allows the interface's ownership semantics to be fully separated from the implementation. I'll agree that no-autorelease refcounting is viable, as is proven by many implementations, but I'll also argue that autorelease adds significant capabilities to the system. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Type Declaration With Protocol
The Objective-C 2.0 Programming Language documentation indicates that a type declaration for an object including a formal protocol should look something like this. id Protocol anObject; I have been studying some sample code that does it like this. NSObject Protocol *anObject; What is the difference between the two? 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: Type Declaration With Protocol
well the first one just says that anObject supports the protocol and it tells you NOTHING else about it at all. So the only methods you can call on it without having the compiler warn you that they may not exist (and they may not exist) are Protocol methods. Seems fine until you actually try it in code and you realise you want to call retain or release or observeKeyValue ... etc. and you get a load of compile errors because the 'normal' methods you expect aren't there. So the second one says that the parameter is an NSObject subclass which supports the Protocol protocol, which means you can call all the usual NSObject things on it. It means you have to pass something which is an NSObject subclass but that's not unusual, most things are right? The NSObject methods are so ubiquitous that I pretty much always use the second form when I'm using a protocol because I almost always want at least some NSObject methods, like release/retain. If you have yet stricter requirements, say you have some class which supports a shape, MyShape and you have a Drawable protocol then you may well use a parameter declared as MyShape Drawable*, which means you guarantee that the parameter is a MyShape subclass (so you can call MyShape methods on it) and it's also Drawable. As NSObject is also a protocol you could probably also do id NSObject, Protocol to say the object supports NSObject and Protocol methods but I never do, partly because it doesn't seem as clear, partly because I know that I'm always going to pass something which is actually descended from NSObject, not just supporting that protocol and partly because the NSObject protocol doesn't have some of the NSObject methods I often end up using. On Mar 14, 2009, at 12:13 PM, Richard Somers wrote: The Objective-C 2.0 Programming Language documentation indicates that a type declaration for an object including a formal protocol should look something like this. id Protocol anObject; I have been studying some sample code that does it like this. NSObject Protocol *anObject; What is the difference between the two? 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/rols%40rols.org This email sent to r...@rols.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