cocoa

iOS8 and Xcode - How to distribute an embedded framework with cocoa pod dependencies

筅森魡賤 提交于 2020-01-22 19:53:26
问题 I need to create a compiled framework for distribution to third parties. I am using cocoa-pods to handle my dependencies. In order to accomplish this, it would seem that that creating a dynamic linked framework is the best option, but I am not sure and open to suggestions. The steps I took are: I created a wrapper project to contain the framework target Inside the wrapper project I added a new target "Cocoa touch framework" - "MyFramework" All of the relevant code is added to the target Added

viewWillAppear or viewDidAppear on NSWindowController

泄露秘密 提交于 2020-01-22 17:43:05
问题 I'm developing an app on MacOS X with Xcode5.1 and there's an action I want to trigger everytime the user opens or shows a NSWindowController all I found was windowDidLoad windowWillLoad awakeFromNib but nothing like in iOS: my methods... viewWillAppear viewDidAppear because even if I close an NSWindowController with [NSWindowController close]; if I open it again, it doesn't trigger my actions from windowDidLoad, windowDidAppear or awakeFromNib and now I need something like them, what's the

Terminating Another App Running - Cocoa

∥☆過路亽.° 提交于 2020-01-22 15:19:31
问题 How can I terminate another app that is running in cooca. Let's say I have iTunes running, and I type in quit in my app, it would quit itunes. "iTunes" is just an example, it could be anything the user wants. I can open any app from my application, but I want to know how to close any app running. thanks kevin 回答1: If you're running on Mac OS X 10.6, Snow Leopard, you can use the new NSRunningApplication terminate method. 回答2: AppleScript is a pretty high-level way to send a single Quit event.

Cocoa Threadsafe Mutable Collection Access

Deadly 提交于 2020-01-22 13:12:52
问题 I'm creating a KVC/KVO-compliant mutable array on one of my objects the recommended way: @interface Factory { NSMutableArray *widgets; } - (NSArray *)widgets; - (void)insertObject:(id)obj inWidgetsAtIndex:(NSUInteger)idx; - (void)removeObjectFromWidgetsAtIndex:(NSUInteger)idx; @end Clearly this is a tricky thread-safety issue. In the insert and remove methods I'm locking around array access to prevent concurrent modification, as recommended. My question is, what is the proper way to implement

Displaying row index in an NSTableView bound to NSArrayController

穿精又带淫゛_ 提交于 2020-01-22 12:29:19
问题 I have an NSTableView which is bound to an NSArrayController. I would like to have one of the table columns showing the index of the table row. This is easy enough to do when you implement NSTableDataSource yourself but I can't figure it out with a bound table view. I guess I'm looking here for something like the @count key path which gives me the count of arrangedObjects (that is @index) but this is obviously missing. Two clarifications: The index that is shown in each row is the index of

How can I read a environmental variable in Cocoa?

*爱你&永不变心* 提交于 2020-01-22 12:21:50
问题 How could I read an environmental variable that a user has set? I'm new to desktop development on the Mac (cocoa), and I am building a little tool that I can use to access amazon's s3 service. I set my environmental variables in my .bash_profile, but I want this to work regardless of where the user entered it (.bashrc, .bash_profile or .profile etc). 回答1: Look at the environment method on a NSProcessInfo. It returns a NSDictionary of the environment so e.g. for PATH NSString* path = [[

OSX status menu not working in Swift

≯℡__Kan透↙ 提交于 2020-01-22 10:06:24
问题 I tried to add a simple status menu to the status bar with swift but it will not be shown. with objective-c this worked: AppDelegate.h @interface AppDelegate : NSObject <NSApplicationDelegate> { IBOutlet NSMenu *statusMenu; NSStatusItem * statusItem; } @end AppDelegate.m @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; [statusItem setMenu:statusMenu]

OSX status menu not working in Swift

≡放荡痞女 提交于 2020-01-22 10:06:04
问题 I tried to add a simple status menu to the status bar with swift but it will not be shown. with objective-c this worked: AppDelegate.h @interface AppDelegate : NSObject <NSApplicationDelegate> { IBOutlet NSMenu *statusMenu; NSStatusItem * statusItem; } @end AppDelegate.m @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength]; [statusItem setMenu:statusMenu]

How to animate the drawing of a CGPath?

ⅰ亾dé卋堺 提交于 2020-01-22 09:46:26
问题 I am wondering if there is a way to do this using Core Animation. Specifically, I am adding a sub-layer to a layer-backed custom NSView and setting its delegate to another custom NSView. That class's drawInRect method draws a single CGPath: - (void)drawInRect:(CGRect)rect inContext:(CGContextRef)context { CGContextSaveGState(context); CGContextSetLineWidth(context, 12); CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 0, 0); CGPathAddLineToPoint(path, NULL, rect

NSPageController tutorial for Cocoa on OS X

孤街醉人 提交于 2020-01-22 09:30:14
问题 I need to use NSPageController in some project but I have no idea how it works, does anybody have time for some simple tutorial to show me because the documentation isn't helping me. Forgot to mention: I'm working on Mac project ( NOT iOS ) 回答1: Simple NSPageController book mode tutorial Create new Cocoa Application -project. Open MainMenu.xib in interface builder and add Image Well and Label objects to your application window. Also add Page Controller object. Set Page Controller's view to