cocoa

Why use dispatch_async when using performSegueWithIdentifier in requestAccessToEntity:completion?

旧城冷巷雨未停 提交于 2020-01-24 10:02:07
问题 When I call the performSegueWithIdentifier in the completion block, if I do not wrap the call in a dispatch_async, it literally takes 10 seconds for the segue to actually happen. However, I can do other things without wrapping them in the same dispatch_async, such as doing core data work, or, logging "things"... Any insight as to how this works and why... I am lost. If this isn't the right place to ask something like this, I apologize. EKEventStore *store = [[EKEventStore alloc] init]; [store

NSTextField bounce truncated text instead of wrapping

徘徊边缘 提交于 2020-01-24 09:30:29
问题 I was wondering if there was a simple way to "bounce" or scroll an NSTextField with text thats too long to display. For Example: ----------------------------- <-- scroll | This is a rather large pi | ..ece of text! ----------------------------- So in this example, the text would scroll to the end, showing the rest of the message, then back to the beginning where it will rest; basically giving the user a peak at all of the text. ----------------------------- This is a ra.. | ther large piece

How can I obtain raw data from a CVImageBuffer object

血红的双手。 提交于 2020-01-24 05:00:28
问题 I'm trying to use cocoa to grab images from a webcam. I'm able to get the image in RGBA format using the QTKit and the didOutputVideoFrame delegate call, and converting the CVImageBuffer to a CIImage and then to a NSBitmapImageRep. I know my camera grabs natively in YUV, what I want is to get the YUV data directly from the CVImageBuffer, and proccess the YUV frame before displaying it. My question is: How can I get the YUV data from the CVImageBuffer? thanks. 回答1: You might be able to create

Geting day number from NSDate

孤者浪人 提交于 2020-01-24 01:07:29
问题 I need to get the day of the week from an NSDate as a number. For example, if today is Thursday I should get number 4, if Friday then number 5. Does this functionality already exist? 回答1: As per your requirement the following codes give you '4' for today i.e. Thursday 13 Dec 2012 NSMutableDictionary *weeks=[NSMutableDictionary new]; [weeks setObject:@"1" forKey:@"Monday"]; [weeks setObject:@"2" forKey:@"Tuesday"]; [weeks setObject:@"3" forKey:@"Wednesday"]; [weeks setObject:@"4" forKey:@

Customise NSLog so it shows less info

杀马特。学长 韩版系。学妹 提交于 2020-01-23 17:51:47
问题 by default NSLog outputs a long string before the requested output, e.g: NSLog(@"Log message"); Outputs to the console: 2011-04-15 11:23:01.692 MyAppName[23160:903] Log message I know I can add the filename and line number to the log, but how do I get rid of all the date, time and app name that appears before the message? I find it really clutters the console in Xcode making it harder to find the information I'm after. 回答1: This is definitely the FIRST thing I do on a new project. NSLog(…)

What do underscore prefixed variable names in Objective-C mean?

[亡魂溺海] 提交于 2020-01-23 13:58:47
问题 I noticed that in many community Objective-C classes and in Apple's frameworks they name some of the variables using a convention that prefixes variables with an underscore, such as: _name . What is the reason for having the underscore. Should I be doing this in my own classes? If so where and when should I use it? 回答1: In Cocoa, it's a convention to indicate the something is private and shouldn't be used externally. However, it's unofficial convention, particularly in light of wording like

Events when dock is showing or hiding

戏子无情 提交于 2020-01-23 11:56:38
问题 How can I get events when the Dock is showing or hiding? 回答1: You can get a notification if the dock is visible or not using Carbon. I do not know of any way to do it in Cocoa. (I haven't tested this; it's from the code here) Create your callback method: #import <Carbon/Carbon.h> static const EventTypeSpec appEvents[] = { { kEventClassApplication, kEventAppSystemUIModeChanged } }; OSStatus DockChangedHandler(EventHandlerCallRef inCallRef, EventRef event, void *userData) { OSStatus status =

NSColorPanel blocking mouse up events

吃可爱长大的小学妹 提交于 2020-01-23 11:21:41
问题 I am using a NSColorWell which is set to continuously update. I need to know when the user is done editing the control (mouse up) from the color picker in the color panel. I installed an event monitor and am successfully receiving mouse down and mouse moved messages, however NSColorPanel appears to block mouse up. The bottom line is that I want to add the final selected color to my undo stack without all the intermediate colors generated while the user is choosing their selection. Is there a

How do you run the rails command from a cocoa application?

纵饮孤独 提交于 2020-01-23 11:20:06
问题 I've been stuck on this one for a while. I'm trying to run a rails shell command from my cocoa application to create a news rails app. When I run ~/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/bin/rails new projectname I'm able to create a new project. But if I run something like this NSString *path = @"~/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/bin/rails"; NSString *script = [NSString stringWithFormat:@"%@ new ~/Desktop/testapp", path]; system([script UTF8String]); or this - (IBAction

Programming for the Apple infared remote controls

梦想与她 提交于 2020-01-23 08:16:06
问题 How do I get started with programming for the Apple infared remote control? To start with, I only intend to support one control, and one type of receiver, that on the current unibody MacBooks. What I mean by programming, is, how do I get started with writing an OSX, preferably Cocoa if there are APIs, app which intercepts commands from the control, and then sends commands to the OS. For example, as a start, I'd like to be able to simply pick up a key press from the remote control, and then