cocoa

How to include OpenCV in Cocoa Application?

蹲街弑〆低调 提交于 2020-01-22 07:52:52
问题 when I create an xCode project with the 'Command Line Tool' c++ stdc++ template, i am able to include and compile opencv headers and run some code. But i want to use OpenCV in a 'Cocoa Application' context. When created with that template, i got compile errors when I include the OpenCV headers in main.mm. (I already changed main.m to main.mm, the '//NSApplicationMain(argc, (const char **) argv);' is commented out) One of those errors is: "Statement-expressions are allowed only inside

In MVC where do you put references to your model Classes?

…衆ロ難τιáo~ 提交于 2020-01-22 07:11:52
问题 I have been wondering for a while, after asking different people and without any of them providing what I would call an "at least a bit concrete answer": Question: Where, in an iPhone application should an application keep the references to it's Model Classes (using the MVC approach) ? In iPhone (and Cocoa) applications we have what we call the "App Delegate", which basically start's up our application and inits our controllers, also handles UITouch events. So is the App Delegate a controller

What is the correct way to handle stale NSURL bookmarks?

一世执手 提交于 2020-01-22 05:39:29
问题 When resolving an NSURL from a security scoped bookmark, if the user has renamed or moved that file or folder, the bookmark will be stale. Apple's document says this regarding staleness: isStale On return, if YES, the bookmark data is stale. Your app should create a new bookmark using the returned URL and use it in place of any stored copies of the existing bookmark. Unfortunately, this rarely works for me. It may work 5% of the time. Attempting to create a new bookmark using the returned URL

Highlighting a NSMenuItem with a custom view?

早过忘川 提交于 2020-01-22 05:33:19
问题 I have created a simple NSStatusBar with a NSMenu set as the menu. I have also added a few NSMenuItems to this menu, which work fine (including selectors and highlighting) but as soon as I add a custom view (setView:) no highlighting occurs. CustomMenuItem *menuItem = [[CustomMenuItem alloc] initWithTitle:@"" action:@selector(openPreferences:) keyEquivalent:@""]; [menuItem foo]; [menuItem setTarget:self]; [statusMenu insertItem:menuItem atIndex:0]; [menuItem release]; And my foo method is: -

get pfx file included in a mobilecertificate in iOS

最后都变了- 提交于 2020-01-21 16:36:17
问题 I'm trying to connect to a server using a .pfx that is stored in a .mobileconfig file on my iPhone. When the server ask for it in -(void)connection:(NSURLConnection*)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge{ How can I create the NSURLCredential with the .pfx? Should I use + (NSURLCredential *)credentialWithIdentity:(SecIdentityRef)identity certificates:(NSArray *)certArray persistence:(NSURLCredentialPersistence)persistence If thats the case, how

get pfx file included in a mobilecertificate in iOS

你离开我真会死。 提交于 2020-01-21 16:36:12
问题 I'm trying to connect to a server using a .pfx that is stored in a .mobileconfig file on my iPhone. When the server ask for it in -(void)connection:(NSURLConnection*)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge{ How can I create the NSURLCredential with the .pfx? Should I use + (NSURLCredential *)credentialWithIdentity:(SecIdentityRef)identity certificates:(NSArray *)certArray persistence:(NSURLCredentialPersistence)persistence If thats the case, how

-[NSTextField intrinsicContentSize] always has undefined width

萝らか妹 提交于 2020-01-21 11:26:27
问题 I'm pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it's stringValue. If I create a textField programmatically like so: _textfield = [[NSTextField alloc] initWithFrame:CGRectZero]; _textfield.translatesAutoresizingMaskIntoConstraints = NO; _textfield.alignment = NSCenterTextAlignment; _textfield.drawsBackground = NO; [_textfield setBordered:NO]; _textfiled.stringValue = @"Test" It's intrinsicContentSize is always (width=-1, height=16) I

-[NSTextField intrinsicContentSize] always has undefined width

和自甴很熟 提交于 2020-01-21 11:25:29
问题 I'm pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it's stringValue. If I create a textField programmatically like so: _textfield = [[NSTextField alloc] initWithFrame:CGRectZero]; _textfield.translatesAutoresizingMaskIntoConstraints = NO; _textfield.alignment = NSCenterTextAlignment; _textfield.drawsBackground = NO; [_textfield setBordered:NO]; _textfiled.stringValue = @"Test" It's intrinsicContentSize is always (width=-1, height=16) I

-[NSTextField intrinsicContentSize] always has undefined width

给你一囗甜甜゛ 提交于 2020-01-21 11:25:28
问题 I'm pulling hairs here. I have an NSTextField created on a xib that has an intrinsicContentSize adjusted to it's stringValue. If I create a textField programmatically like so: _textfield = [[NSTextField alloc] initWithFrame:CGRectZero]; _textfield.translatesAutoresizingMaskIntoConstraints = NO; _textfield.alignment = NSCenterTextAlignment; _textfield.drawsBackground = NO; [_textfield setBordered:NO]; _textfiled.stringValue = @"Test" It's intrinsicContentSize is always (width=-1, height=16) I

Resizing the window according to a variable swift

元气小坏坏 提交于 2020-01-21 04:50:06
问题 I have a NSViewController and a variable num . I want to change the size of the window dynamically according to that variable. Is there any way to do that in swift? 回答1: Let's say your window has an IBOutlet named "window", and your dynamic number is named "myDynamicNumber": func resize() { var windowFrame = window.frame let oldWidth = windowFrame.size.width let oldHeight = windowFrame.size.height let toAdd = CGFloat(myDynamicNumber) let newWidth = oldWidth + toAdd let newHeight = oldHeight +