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
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.
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,
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
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];
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,
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
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
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 =
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
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) +
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
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
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
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
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
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
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.
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
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
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
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
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
23 matches
Mail list logo