This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; | |
[animationGroup setAnimations:[NSArray arrayWithObjects:simpleAnimationOne, simpleAnimationTwo, nil]]; | |
[animationGroup setDuration:1.0f]; | |
[animationGroup setAutoreverses:YES]; | |
[[moveMe layer] addAnimation:animationGroup forKey:@"group action"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface NSNotificationCenter (ObserverAdditions) | |
- (void)registerObserver:(id)observer | |
forName:(NSString *)name | |
object:(id)obj | |
queue:(NSOperationQueue *)queue | |
usingBlock:(void (^)(NSNotification *))block; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet | |
usingRect:(NSRect)rect | |
{ | |
rect.origin.y -= 14; // or as much as we need | |
return rect; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)routerMACAddress { | |
NSMutableString *MACAddress = [NSMutableString string]; | |
SCDynamicStoreRef theDynamicStore = SCDynamicStoreCreate(nil, CFSTR("FindCurrentInterfaceAndIP"), nil, nil); | |
CFDictionaryRef returnedPList = SCDynamicStoreCopyValue(theDynamicStore, CFSTR("State:/Network/Global/IPv4")); | |
CFRelease(theDynamicStore); | |
if ([(__bridge NSDictionary *)returnedPList valueForKey:@"Router"] != nil) { | |
NSTask *arpTask = [[NSTask alloc] init]; | |
NSPipe *newPipe = [NSPipe pipe]; | |
NSFileHandle *readHandle = [newPipe fileHandleForReading]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSImage (GIF) | |
- (BOOL)isGifImage; | |
- (BOOL)saveAnimatedGIFToFile:(NSString*)filepath; | |
@end | |
@implementation NSImage (GIF) | |
- (BOOL)isGifImage | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSImage *)resizeTo:(NSSize)newsize | |
{ | |
NSImage *resizedImage = [[NSImage alloc] initWithSize:newsize]; | |
NSSize originalSize = [self size]; | |
[resizedImage lockFocus]; | |
[self drawInRect: NSMakeRect(0, 0, newsize.width, newsize.height) fromRect: NSMakeRect(0, 0, originalSize.width, originalSize.height) operation: NSCompositeSourceOver fraction: 1.0]; | |
[resizedImage unlockFocus]; | |
#if __has_feature(objc_arc) | |
return resizedImage; | |
#else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSWindow (FullScreen) | |
- (BOOL)isFullScreen; | |
@end | |
@implementation NSWindow (FullScreen) | |
- (BOOL)isFullScreen | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
@interface AsyncCopyController : NSObject | |
-(OSStatus)copySource : (NSString *)aSource ToDestination: (NSString *)aDestDir setDelegate : (id)object; | |
//delegate method | |
-(void)didReceiveCurrentPath : (NSString *)curremtItemPath bytesCompleted : (unsigned long long)floatBytesCompleted currentStageOfFileOperation : (unsigned long)stage; | |
-(void)didCopyOperationComplete : (BOOL)boolean; | |
-(void)didReceiveCopyError : (NSString *)Error; | |
-(void)cancelAllAsyncCopyOperation; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.beyondcow.Miao"]) { | |
//if find Miao on this Mac then post text via Miao system service port | |
NSString *text = @"Hello world!"; | |
[[NSPasteboard generalPasteboard] clearContents]; | |
[[NSPasteboard generalPasteboard] setString:text forType:NSStringPboardType]; | |
NSPerformService(@"Miao Post Weibo", [NSPasteboard generalPasteboard]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AppDelegate.h" | |
@interface NSStatusBar(Private) | |
- (id)_statusItemWithLength:(double)length withPriority:(int)priority; | |
@end | |
@interface AppDelegate() | |
{ | |
NSStatusItem *item; | |
} |
OlderNewer