Skip to content

Instantly share code, notes, and snippets.

@beelsebob
Created August 1, 2011 10:42
@implementation MyDocument
- (void)dealWithCompressionFinished:(TextureAtlas *)ta
{
[textureController closeCompressingSheet];
if (nil == [ta previewImage])
{
[[NSAlert alertWithMessageText:@"Invalid Texture"
defaultButton:@"OK"
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"Textures must be square, have a power of two number of pixels high/wide and be at least 8 pixels high and wide"]
beginSheetModalForWindow:[self windowForSheet]
completionHandler:^(NSInteger result){}];
}
}
@end
#import "NSAlertWithBlocks.h"
@interface NSAlert (WithBlocksPrivate)
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
@end
@implementation NSAlert (WithBlocks)
- (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void(^)(NSInteger result))completionHandler
{
[self beginSheetModalForWindow:window modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:[completionHandler copy]];
}
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
void(^handler)(NSInteger result) = (void(^)(NSInteger result))contextInfo;
handler(returnCode);
[handler release];
}
@end
#0 0x00007fff9836f5b6 in fsync ()
#1 0x00007fff91e23641 in -[CFXPreferencesPropertyListSourceSynchronizer writePlistToDisk] ()
#2 0x00007fff91dec355 in -[CFXPreferencesPropertyListSourceSynchronizer synchronizeAlreadyFlocked] ()
#3 0x00007fff91dec0b2 in -[CFXPreferencesPropertyListSourceSynchronizer synchronize] ()
#4 0x00007fff91debd3c in -[CFXPreferencesPropertyListSource synchronize] ()
#5 0x00007fff91e19752 in -[CFXPreferencesSearchListSource synchronize] ()
#6 0x00007fff91e21aa1 in ___CFXPreferencesAppSynchronize_block_invoke_1 ()
#7 0x00007fff91deb0f0 in ____CFXPREFS_SYNC_LOCKED_block_invoke_1 ()
#8 0x00007fff94543afd in _dispatch_barrier_sync_f_invoke ()
#9 0x00007fff91e21a44 in CFPreferencesAppSynchronize ()
#10 0x00007fff984e2ff9 in TalkingAlertsEnabled ()
#11 0x00007fff93229954 in -[NSAlert startTimerForSpeaking] ()
#12 0x00007fff9322adc2 in -[NSAlert beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:] ()
#13 0x000000010001bf00 in -[NSAlert(WithBlocks) beginSheetModalForWindow:completionHandler:] at /Users/tatd2/Documents/HuntedCow/My/Classes/CocoaExtensions/NSAlertWithBlocks.m:22
#14 0x0000000100005519 in -[MyDocument dealWithCompressionFinished:] at /Users/tatd2/Documents/HuntedCow/My/Classes/Editor Controllers/MyDocument.m:434
#15 0x00007fff91e3611d in -[NSObject performSelector:withObject:] ()
#16 0x00007fff96c36830 in __NSThreadPerformPerform ()
#17 0x00007fff91db5241 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#18 0x00007fff91db4aad in __CFRunLoopDoSources0 ()
#19 0x00007fff91ddb8d9 in __CFRunLoopRun ()
#20 0x00007fff91ddb216 in CFRunLoopRunSpecific ()
#21 0x00007fff909a94ff in RunCurrentEventLoopInMode ()
#22 0x00007fff909b0c21 in ReceiveNextEventCommon ()
#23 0x00007fff909b0aae in BlockUntilNextEventMatchingListInMode ()
#24 0x00007fff92f82191 in _DPSNextEvent ()
#25 0x00007fff92f81a95 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#26 0x00007fff92f7e3d6 in -[NSApplication run] ()
#27 0x00007fff931fc52a in NSApplicationMain ()
#28 0x00000001000c52a2 in main at /Users/tatd2/Documents/HuntedCow/My/editorMain.m:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment