2018-10-21         Broderick

Swift protocols: method does not override any method from its superclass

Since Xcode 6 still has a lots of bugs with Swift, I'm not sure is it one or I'm missing something.My class adopts protocol NSLayoutManagerDelegate. But it seems impossible to override method I need. I do as documentation describes:override func layoutManager(_ aLayoutManager: NSLayoutManager!, didCompleteLayoutForTextContainer aTextContainer: NSTextContainer!, atEnd flag: Bool) { }But I get error here: method does not override any method from its superclass.What should I do? You're implementing a method from the protocol, yes, but it's not an override. ...

 cocoa                     2 answers                     6 view
 2018-10-21         Stan

Create unique-member collections in Swift

I don't see any way of guaranteeing uniqueness of the members of a Swift array/collection like Cocoa NSSets. If this is true, then I wonder what else is missing from Swift, vs Cocoa?What am I missing, if anything? What you're missing is that NSSet and the rest of Foundation, Cocoa, etc. is still there and always will be.EDIT: In Swift 1.2, Set is a native Swift type and you'll use that instead.There's absolutely nothing wrong with using NSSet when you need to. Here's an example from my own code:class TracksViewController : UITableViewController { // ... var observ...

 cocoa                     2 answers                     9 view
 2018-10-21         Ophelia

How to initialize a NSWindowController in Swift?

I want to initialize a window controller object from a nib file, quite easy right? But I simply can't get it to work.According to my previous experience in ObjC, I've written down the following code:init() { super.init(windowNibName: "SplitWindowController")}And in the app delegate file, I simply init and displays the window:var myWindowController: MyWindowController = MyWindowController()myWindowController.showWindow(self)myWindowController.window.makeKeyAndOrderFront(nil)But the compiler gives me this error: Must call a designated initializer of the superclass 'NSWind...

 cocoa                     2 answers                     10 view
 2018-10-21         Duke

How to add Command-Q logic in Cocoa with Swift?

I want to add some logic in my Cocoa app when an user puts Command-Q to try to quit the app, but how can I add it in Swift?What I want to do is something like this, but this is on Objective-C and when I tried to port it to my Swift app, it doesn't succeed since it looks like applicationShouldTerminate is no longer available in Swift, given that it doesn't react to the completion of the method in my Xcode.Also, when I tried to write NSTerminateNow like the one written on the post above, I got an unresolved error, so NSTerminateNow is also gone in Swift and Xcode 6.So if I wa...

 cocoa                     2 answers                     12 view
 2018-10-21         Emily

Swift - CLLocationManager not asking for user permission

I am with Xcode beta 2 and trying to get user location with OS X app, however it is not even asks user permission. here is what I did until now. ...import CoreLocationclass AppDelegate: NSObject, NSApplicationDelegate, CLLocationManagerDelegate { var locManager : CLLocationManager = CLLocationManager() func applicationDidFinishLaunching(aNotification: NSNotification?) { locManager.delegate = self locManager.desiredAccuracy = kCLLocationAccuracyBest locManager.startUpdatingLocation() } func locationManager(manager: CLLocationManager!, didUp...

 cocoa                     1 answers                     13 view
 2018-10-21         Sean

How to do View Controller callback in Swift

I am trying to do a callback from a child view controller back to its parent. The value passed back is printed successfully but I then get an EXC_BAD_INSTRUCTION.In the parent view controller I construct the child controller like so:let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)if let vc = storyboard.instantiateViewControllerWithIdentifier("dataEntryView") as? DataEntryViewController { dataEntryVC = vc vc.callback = calculateHeartRate self.presentViewController(dataEntryVC!, animated: true, completion: nil)}I call back from the child contro...

 cocoa                     2 answers                     14 view
 2018-10-21         Bonnie

ViewController vs. View

Trying to wrap my head around the apple design scheme. I have a UIViewController and the corresponding XIB file that has my main screen in my application. I want to have a button on this XIB that displays another "form" (this is my disconnect) in the foreground where the user selects from a myriad of choices, then it hides that "form" and goes back to the first one.I'm completely lost here. Initially I thought I'd just add another view and set the self.view of my controller to the new view, add another IBAction and call it a day, but I can't seem to make that work. For ...

 cocoa                     1 answers                     97 view
 2018-10-21         Burnell

UINavigationController-Alike for Desktop-Cocoa?

I'm currently developing an application with an user interface much like Twitter for Mac (Pushing in/out of views like on iOS). Has anyone implemented a UIViewController for desktop Cocoa? This would save me many hours of work. There isn't one in standard AppKit at this time. You'll have to write your own.This may help if you decide to go down that path: http://parsekit.com/umekit/UMEKit is a little framework for Cocoa that implements some equivalents to UIKit classes and UI components. [XXX]I spent ages looking for this and started to write my own, then found https:/...

 cocoa                     3 answers                     3 view
 2018-10-21         Lewis

How to make something like Twitter for Mac top bar or GitHub's one?

I'm making an app and seen that twitter has this style for navigating through views (like iOS UINavigationController):Is there any control that emulates that behavior? Take a look PXNavigationBar, it features this kind of breadcrumb navigation bar. However, about this specific type of control, I might be wrong, but I think this is part of the Chameleon project (used by the GitHub for Mac app) and/or TwUI (Twitter for Mac UI). [XXX]

 cocoa                     1 answers                     81 view
 2018-10-21         Payne

How to specify key bindings in a dict file inside Cocoa app bundle?

(This is not a question about KVC/KVO and key-value bindings.)I'm writing an application with a "tools" panel. Every tool can be selected using one-letter key (like "M" - "Move tool"). Tool can be selected even when there is no main window and the tools panel is not selected (not being "key").Docs say that raw key events are not propagated to the app delegate and document controller (so I cannot rely on onKeyDown since it should happen in a WindowController). But "action events" (keys bound to a selector) are sent to the app, app delegate and document controller.I know two ...

 cocoa                     2 answers                     52 view
 2018-10-21         Joanne

How to print and use constants with gdb (through Xcode)?

I am debugging a Cocoa application using xcode-gdb. I am at a break point and I want view the value of some Cocoa constants (ie NSControlKeyMask) and to do some test with the values in the current stackframe. Specifically I am in - (void) keyDown:(NSEvent *) e , and I have done set $mf = (int)[e modifierFlags] on the gdb prompt. Now I want to do p $mf & NSControlKeyMask and gdb is telling me 'No symbol "NSControlKeyMask" in current context.'UPDATE:Xcode has the "Fix and Continue text" feature. So I used Dan M. and n8gray solution with this feature so I don't have t...

 cocoa                     5 answers                     53 view
 2018-10-22         Jennifer

How to create a Vertical progressbar in Cocoa?

I'm trying to create a vertical progress bar in my Cocoa app, i.e, the progress bar should grow from bottom to top. I'm using NSProgressIndicator, and I can't find a way to specify vertical or horizontal. Can anybody please tell me is it possible to do it?Thanks,Lee You can set the transform of the control to rotate it pi/2 radians (90 degrees). That seems to be a common solution most people take. [XXX]import UIKitclass ViewController: UIViewController {// THis is custom Progress viewvar progessView:VerticalProgressView!// We can also use default progress view given b...

 cocoa                     2 answers                     92 view
 2018-10-22         Mike

Hyperlink in Cocoa

I am developing a Mac application in XCode. I need to add a hyperlink which navigates to a particular site. I tried this using a button, but I need to know how to change the cursor to hand cursor when mouse is over that button. I believe you can use a non-editable NSTextField to display the URL. If you set the attributes appropriately on the NSAttributedString that you set as the field's value property, it will display as the standard blue-with-underline and handle the cursor tracking for you. This Apple Q&A tells you how to set the attributes for a URL. [XXX]To s...

 cocoa                     3 answers                     101 view
 2018-10-22         Ophelia

Removing url fragment from NSURL

I'm writing a Cocoa application, which uses NSURLs -- I need to remove the fragment portion of the URL (the #BLAH part).example: http://example.com/#blah should end up as http://example.com/I found some code in WebCore that seems to do it by using CFURL functionality, but it never finds the fragment portion in the URL. I've encapsulated it in a extension category:-(NSURL *)urlByRemovingComponent:(CFURLComponentType)component { CFRange fragRg = CFURLGetByteRangeForComponent((CFURLRef)self, component, NULL); // Check to see if a fragment exists before decomposing the ...

 cocoa                     3 answers                     86 view
 2018-10-22         Zenobia

Configuring NSPredicateEditor(RowTemplate) for Spotlight metadata queriesI'

I'm trying to configure an NSPredicateEditor (in Interface Builder) to edit the predicate for an NSMetadataQuery. As a first step, I'm trying to configure an NSPredicateEditorRowTemplate to accept key path(s) for the left-side expression, trying a single keyPath (kMDItemTextContent) to get started.I can't figure out how to get all the pieces into IB. I've selected the row template, and set "Left Exprs" to "Key Paths" in the IB Attributes Inspector. But, using Apple's PhotoSearch example as a model, it appears that I should enter a user-readable attribute name (say, "Content...

 cocoa                     1 answers                     84 view
 2018-10-22         Phoebe

Cocoa menubar programmatically with NSMenu, how to get standard items "Services", "Hide App", "Hide Others", "Show All" etc

In decarbonizing I have now come to creating a menubar programmatically using NSMenu.Carbon seems to be so nice to add standard items to the application menu: Services, Hide app, Hide Others, Show All, Quit app,and they are even added using the user’s Preferred Language setting in System Preferences’s Language & Region,so in German Hide Others is added as Andere ausblenden.I only had to add the About and Preferences items.However, it seems that in Cocoa I have to add these standard items myself,but how can I find out what Hide Others is called in the user’s Preferred La...

 cocoa                     1 answers                     43 view

Page 1 of 92  |  Show More Pages:  Top Prev Next Last