Re: Base64 encoding of NSImage

2012-07-01 Thread David Riggle
This is what I use. Short and sweet. @implementation NSData (Base64) - (NSData *)dataWithBase64Encoding { CFDataRef retval = NULL; SecTransformRef encodeTrans = SecEncodeTransformCreate(kSecBase64Encoding, NULL); if (encodeTrans != NULL) { if

Re: creating a favorites bar

2012-03-19 Thread David Riggle
I wanted something similar recently (especially the drag drop rearranging). I didn't find anything suitable on the web and had to implement it all from scratch. Despite being mentioned in the Apple HIG, there is no OS support for scope bars.

e: setAllowedFileTypes: (or similar) for NSPasteboard

2012-03-04 Thread David Riggle
I think you also need to register for the drag types via -registerForDraggedTypes. I pass in a mix of UTIs and legacy pboard types and it seems to work. For example: [tableView registerForDraggedTypes:[NSArray arrayWithObjects:(NSString *)kUTTypeURL, NSPasteboardTypeString,

Fwd: NSPasteboardItem kPasteboardTypeFileURLPromise

2012-02-29 Thread David Riggle
I've been struggling with the new NSPasteboard APIs as well. The lack of sample code is appalling. I finally got file promises to work by incorporating some low level pasteboard manager calls. Note that NSPasteboard is not toll-free bridged with PasteboardRef, but you can go back forth between

Re: How to detect clicks outside of modal window?

2011-11-04 Thread David Riggle
Subclass NSApplication and override this method: - (NSEvent *)nextEventMatchingMask:(NSUInteger)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag { NSEvent *event = [super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:deqFlag];

Re: Core Data: Determine if managed object is deleted

2011-10-23 Thread David Riggle
I don't know if all those tests are necessary. I did show the method to a Core Data engineer at WWDC one year and he thought it looked OK. Those are good points about -prepareForDeletion. I was just experimenting for the heck of it. I guess if it ain't broke I shouldn't fix it. :) On Oct 22,

Re: Core Data: Determine if managed object is deleted

2011-10-21 Thread David Riggle
This is what I have used for years with good success: - (BOOL)retainedObjectHasBeenDeleted { // if object has been deleted, then it no longer exists if ([self isDeleted]) return YES; // otherwise, see if object with this ID exists in the database

Re: Sandboxing and file references

2011-09-22 Thread David Riggle
The explicit entitlement to read a file following an open/drag exists only until the application quits (a fragile exception exists in using URLs stored into the restorable state archive, but even that won't work long term). Â Thus keeping references to files is essentially impossible (long

Re: CoreFoundation object over-retained during finalization

2011-03-12 Thread David Riggle
I've seen similar SecKeychain crashes whenever I put runtime code signing checks into my code. I suspect SecKeychain is not garbage collection safe. I've taken to doing the following to eliminate the crashes: [[NSGarbageCollector defaultCollector] disable]; err =

Changing the drag image on the fly

2010-04-08 Thread David Riggle
I'd like to change the drag image based on the drop location, the way iCal does. I found this tantalizing snippet in the WebCore code: if (cocoaImage) { // Dashboard wants to be able to set the drag image during dragging, but Cocoa does not allow this. // Instead we

Re: Julian date

2010-01-08 Thread David Riggle
These two methods work fine for my astronomical calculations. Maybe they'll be inaccurate after 2100. Beats me. The world's going to end in 2012 anyway. ;) @implementation NSDate (JulianDates) - (NSTimeInterval)julianDate { return ([self timeIntervalSince1970] / 86400.0) +

Re: NSUndoManager auto-grouping?

2009-12-18 Thread David Riggle
This post describes how to dump the NSUndoManager stacks. I found it helpful when debugging undo manager crashes. http://parmanoir.com/Inspecting_NSUndoManager's_undo_stack ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post

Outing the poseAsClass: poseur

2009-12-11 Thread David Riggle
I still get reports of this crash: #8 0x968b411d +[%NSToolbarView _findFirstKeyViewInDirection:forKeyLoopGroupingView:] (see http://lists.apple.com/archives/cocoa-dev/2009/Aug/msg01974.html) I would like to know what hack is responsible. Is there a way to find the name of the application that

What's the friendliest way to restart the Dock?

2009-10-30 Thread David Riggle
My app uses an NSDockTilePlugin. When I update my app via Sparkle, I want the new dock plug-in to be loaded. Unfortunately, the SystemUIServer has already loaded the old plug-in and ignores the new plug-in. Ditto for the Dock. There's no API that I've found to force a dock plug-in to be

NSDockTilePlugIn

2009-09-08 Thread David Riggle
I've been experimenting with an NSDockTilePlugIn. The documentation is a bit sparse. It looks like the plug-in needs to be 32-bit/64-bit GC supported. The plug-in gets called successfully in the release build of my app, but it does not get called in the debug build. Instead, I get this

NSInternalInconsistencyException -- keyLoopGroupingView should be a NSToolbarView

2009-08-31 Thread David Riggle
How do I prevent this crash? It happens occasionally when I call [NSView nextValidKeyView] or [NSWindow selectKeyViewFollowingView:] in a window that has a toolbar. Here's a typical stack trace: #6 0x948f2dcb +[NSException raise:format:arguments:] #7 0x92e9fec4 -[NSAssertionHandler

libcrypto on Snow Leopard

2009-08-28 Thread David Riggle
I converted my project to the 10.6 SDK, but now my app won't launch on Leopard: myApp[595]: dyld: Library not loaded: /usr/lib/libcrypto.0.9.8.dylib myApp[595]: Referenced from: /Users/dave/Desktop/myApp.app/Contents/ myApp myAppl[595]: Reason: image not found If I select the older

strncat on Leopard vs. Snow Leopard

2009-08-28 Thread David Riggle
When I compile my app on Snow Leopard and run it on Leopard, strncat erroneously aborts with detected buffer overflow. I think there was a bug in the Leopard version of strncat that was fixed in the Snow Leopard version.

Re: Code signing validation

2008-10-28 Thread David Riggle
I just pass the -o kill flags to codesign. That way if the app has been tampered with it won't launch. Make sure you are using Xcode 3.1 or later so the codesigning is done after the stripping. Dave ___ Cocoa-dev mailing list

Core Data: fetching keypaths through abstract entities

2008-10-19 Thread David Riggle
I want to use a keypath that goes through an abstract entity down into a concrete sub-entity. For example, given this data model: Abstract entity: person Concrete sub-entities: man, woman Abstract entity: club relationship: members (- person) Concrete sub-entities: allMale, coed I want to

[ABAddressBook addressBook] vs. [ABAddressBook sharedAddressBook]

2008-09-23 Thread David Riggle
What is the use of the new Leopard call [ABAddressBook addressBook]? I played around with it, and it seems to be functionally equivalent to [ABAddressBook sharedAddressBook]. Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do

Re: [ABAddressBook addressBook] vs. [ABAddressBook sharedAddressBook]

2008-09-23 Thread David Riggle
as they did when using the sharedAddressBook. Queries to the private address book returned everything from the Address Book application. Dave On Sep 23, 2008, at 4:53 PM, Ricky Sharp wrote: On Sep 23, 2008, at 5:44 PM, David Riggle wrote: What is the use of the new Leopard call

Re: NSCalendarDate to be deprecated

2008-08-18 Thread David Riggle
I wish NSCalendarDate could be fixed instead of discarded. I find it a convenient class, and it is heavily used in the standard sync schemas. If it must go, I hope somebody comes up with an open source replacement for it. :) Dave ___ Cocoa-dev