Construct and manage a graphical, event-driven user interface for your macOS app using AppKit.

AppKit Documentation

Posts under AppKit tag

245 Posts
Sort by:
Post not yet marked as solved
9 Replies
2.8k Views
I want to implemtn a swipeable cell view like in iOS for an OSX app. I haven't found any discussion or tutorial for this requirement, but I have seen already mac applications with sipeable content.
Posted
by
Post not yet marked as solved
6 Replies
3.1k Views
I've built a Framework which I would like to use it in other applications.I know the basics on including and using frameworks.The problem is I really have TWO Frameworks the Device Framework and the Simulator Framework.Is there a way to tell XCode to use the right Framework?
Posted
by
Post not yet marked as solved
4 Replies
1.2k Views
I am integrating FinderSync Extension in my Cocoa Application to show badges in files and folders. Look at the below two scenario:1) When i run application using FinderSync Extension (like DemoFinderSync), in that case Extension is added in the System Preference with Check mark and called that principal class "FinderSync.m" as well.2) When i run application using my Application Scheme (like DemoApp) , in that case Extension is added in the System Preference but without check mark and that principal class "FinderSync.m" do not call and FinderSync Extension does not work in this case.So anybody have an idea how to enable Finder Extension in the System Preference using second scenario.Also post your answer in the below StackOverflow link:http://stackoverflow.com/questions/31176942/how-to-enable-findersync-extension-in-the-system-preference-in-cocoa-objectiveAny help is appreciated..!!
Posted
by
Post marked as solved
2 Replies
1.4k Views
I am using storyboards for a Mac OS X programs and have a Tab View Controller. When the Tab View Controller is segued onto to screen I would like to do some setup on each of the view controllers for the tabs.The documentation for the NSTabViewController states: "Each tab is represented by an NSTabViewItem object, which contains the name of the tab and stores a pointer to the child view controller that manages the tab’s content."This is exactly what I want - "a pointer to the child view controller that manages the tab’s content." Great!But no so great -- there is no variable or method in NSTabViewItem that gives me a pointer to a view controller!! I find this very confusing. I have scanned the documentation of NSTabViewItem from top to bottom, plus looked that the header file. There is no mention of a "pointer to the child view controller" anywhere!The documentation clearly states that this pointer is there - but I can't find it. Am I missing something obvious?Thanks.
Posted
by
Post marked as solved
6 Replies
2.6k Views
Hello,The same way there is a framework and API to add events and reminders to the Mac calendars, I'd like to know if there is an API to create notes from a custom application, so that they will later be accessible through the OS X Notes application ?Thank you.
Posted
by
Post not yet marked as solved
5 Replies
3.7k Views
I'm trying to use the Accessibility API and have this code: NSDictionary *options = @{(__bridge id) kAXTrustedCheckOptionPrompt : @YES}; BOOL accessibilityEnabled = AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef) options);This always returns no, however it does not prompt the user for permission nor does it display the app's name in System Preferences > Security & Privacy. What do I need to test this? I could try and add the debug version manually into System Preferences but how do I know that this will work properly when released to the public? Is there any way to test this out? I am not seeing any prompt at all.
Posted
by
Post marked as solved
5 Replies
1.1k Views
Hi,I've been usingIOReturn success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &assertionID);as detailed in this Tech Q & A to prevent the screen saver from activating in certain phases of my app. Unfortunately, since 10.11 this seems to have stopped working. There are no errors, no extra log lines generated, the app works absolutely fine and the only difference in it's operation - in El Capitan - is that the screen saver continues to show after the prerequisite amount of time.Does anyone know if there's been a change to the process of preventing this? I can't seem to find anything in docs...Todd.
Posted
by
Post not yet marked as solved
2 Replies
360 Views
In recent versions of OS X—I think this was introduced in Yosemite—changing the default browser by calling LSSetDefaultHandlerForURLScheme displays a prompt that gives the user the option of accepting the new default browser, or sticking with their existing one:Do you want to change your default web browser to “new browser” or keep using “old browser”?Your default web browser opens when you click links in places like email messages, documents, and other apps.The call to LSSetDefaultHandlerForURLScheme returns immediately, before the user has responded to this prompt, so checking the return value doesn't give any indication of the user's choice.Is anyone aware of a way of checking what the user chose? There's some UI in my application that should change to indicate if it's currently the default browser, so it's useful to know if the call to LSSetDefaultHandlerForURLScheme resulted in a change.I haven't been able to find any documentation about this prompt. I have no problem with the prompt appearing, but if bypassing it is an option that'd be fine too.
Posted
by
Post not yet marked as solved
1 Replies
1.1k Views
Showing a popover from a status bar item. Sometimes results in this being logged out:Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored.Please fix this problem.When this happens, the popover appears at 0.0,0.0 (lower left) of the screen for a second... before snapping to the proper position.Code: NSStatusBarButton *statusButton = _statusItem.button; [_popover showRelativeToRect:statusButton.bounds ofView:statusButton preferredEdge:NSMinYEdge];The user can add or remove the status item in this app...the issue I notice usually happens the second time the popover gets presented. Looks like the popover can be trying to present before the status item button's position is set?
Post not yet marked as solved
2 Replies
729 Views
I have an NSTableView (view based). The cells (views) have a NSImageView to display a thumbnail.Thumbnails come from the web, and I load the thumbnails lazily. My class that handles the thumbnail loading has a delegate that sends back a message like this:-(void)thumbnailCache:(nonnull MyThumbnailCacheObject*)thumbnailCache loaddedThumbnailsForURLs:(nonnull NSArray<NSURL*>*)imageURLs { //Get the row indexes for the urls...and then call....reloadDataForRowIndexes:columnIndexes //table view doesnt have columns. [self.tableView reloadDataForRowIndexes:indexes columnIndexes:[NSIndexSet indexSetWithIndex:0]]; }However the cells don't update. At first I thought it was a bug in my thumbnail loading, but a call to reloadData does update the cells properly.Wrapping the reloadDataForRowIndexes:columnIndexes: in between beginUpdates and endUpdates calls makes no difference.Does reloadDataForRowIndexes:columnIndexes: not work with view based table views? I'm tempted to just use reloadData and hope everything works out okay.
Post not yet marked as solved
4 Replies
1.4k Views
Hey guys,We want to be able to copy a file created in Voice Memos into our application. The format voice memos saves a file in is m4a, except when we try to import the file into our application, iOS doesn't recognise our app as an option. I can't seem to find a UTI type that accepts this. All the standard .m4a UTI types don't seem to work. Does anyone know what the UTI type is to allow us to copy a file from voice memos across?This is the current entry we have in our Info.plist for CFBundleDocumentTypes:<dict> <key>CFBundleTypeName</key> <string>.m4a</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Alternate</string> <key>LSItemContentTypes</key> <array> <string>public.mpeg4</string> <string>public.mpeg-4-audio</string> <string>com.apple.protected-mpeg-4-audio</string> <string>public.audio</string> </array></dict>The full list of UTI types is available here: https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1Any help really appreciated as I'm stuck on this.Tim
Posted
by
Post not yet marked as solved
0 Replies
455 Views
Hello there,I am sure people have encountered this issue but I wasn't able to find it around here. Given a NSTableView or a NSOulineView that can be bound with a NSArrayController or a NSTreeController, how does that go with Swift arrays.. Swift Array aren't NSMutableArray, however, removing a selected object seem to work fine. It starts to go wrong when dragging an object to another spot in the collection view.Here is the stacktrace. But the question is, is there a workaround to achieve this without using NSMutableArray.. Imagine you have a complex strong-typed model with different levels of children.-[_TtCs21_SwiftDeferredNSArray removeObjectIdenticalTo:]: unrecognized selector sent to instance 0x618000027980 2016-04-15 20:20:21.954 Test[80244:8446095] ( 0 CoreFoundation 0x00007fff87f394f2 __exceptionPreprocess + 178 1 libobjc.A.dylib 0x00007fff900ddf7e objc_exception_throw + 48 2 CoreFoundation 0x00007fff87fa31ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x00007fff87ea9571 ___forwarding___ + 1009 4 CoreFoundation 0x00007fff87ea90f8 _CF_forwarding_prep_0 + 120 5 AppKit 0x00007fff93350344 -[NSTreeControllerTreeNode removeObjectFromSubNodesAtIndex:] + 516 6 AppKit 0x00007fff932ad41e -[NSTreeController moveNodes:toIndexPath:] + 474 7 Test 0x00000001000030e4 _TFC4Test14ViewController11outlineViewfTCSo13NSOutlineView10acceptDropPSo14NSDraggingInfo_4itemGSqPs9AnyObject__10childIndexSi_Sb + 404 8 Test 0x00000001000031e4 _TToFC4Test14ViewController11outlineViewfTCSo13NSOutlineView10acceptDropPSo14NSDraggingInfo_4itemGSqPs9AnyObject__10childIndexSi_Sb + 100 9 AppKit 0x00007fff93148096 -[NSOutlineView performDragOperation:] + 324 10 AppKit 0x00007fff92dc06dc NSCoreDragReceiveMessageProc + 260 11 HIServices 0x00007fff94454e4a DoMultipartDropMessage + 328 12 HIServices 0x00007fff94454b54 DoDropMessage + 41 13 HIServices 0x00007fff94454b25 SendDropMessage + 80 14 HIServices 0x00007fff944537f3 DragInApplication + 505 15 HIServices 0x00007fff94452611 CoreDragStartDragging + 535 16 AppKit 0x00007fff92dbd435 -[NSCoreDragManager _dragUntilMouseUp:accepted:] + 1010 17 AppKit 0x00007fff92dba623 -[NSCoreDragManager dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:] + 1212 18 AppKit 0x00007fff92dba155 -[NSWindow(NSDrag) dragImage:at:offset:event:pasteboard:source:slideBack:] + 135 19 AppKit 0x00007fff9314706e -[NSOutlineView dragImage:at:offset:event:pasteboard:source:slideBack:] + 221 20 AppKit 0x00007fff93212d90 -[NSTableView _doImageDragUsingRowsWithIndexes:event:pasteboard:source:slideBack:startRow:] + 539 21 AppKit 0x00007fff93213bdc -[NSTableView _performClassicDragOfIndexes:hitRow:event:] + 329 22 AppKit 0x00007fff92dfad95 -[NSTableView _performDragFromMouseDown:] + 463 23 AppKit 0x00007fff92df9518 -[NSTableView mouseDown:] + 705 24 AppKit 0x00007fff92df901e -[NSOutlineView mouseDown:] + 74 25 AppKit 0x00007fff932ce469 -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6322 26 AppKit 0x00007fff932cf44d -[NSWindow _reallySendEvent:isDelayedEvent:] + 212 27 AppKit 0x00007fff92d0e63d -[NSWindow sendEvent:] + 517 28 AppKit 0x00007fff92c8eb3c -[NSApplication sendEvent:] + 2540 29 AppKit 0x00007fff92af5ef6 -[NSApplication run] + 796 30 AppKit 0x00007fff92abf46c NSApplicationMain + 1176 31 Test 0x00000001000045a4 main + 84 32 libdyld.dylib 0x00007fff900c65ad start + 1 33 ??? 0x0000000000000003 0x0 + 3 )Thank you for your help
Posted
by
Post not yet marked as solved
3 Replies
500 Views
Am I doing something wrong or is it a bug? I am getting 21000 year when parsing 01/01/00 string to date using the "MM/dd/yy" format: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MM/dd/yy"]; NSDate *originalDate = [NSDate dateWithTimeIntervalSinceReferenceDate:-24 * 60 * 60 * 366]; NSString *jan01String = [dateFormatter stringFromDate:originalDate]; NSDate *jan01Date = [dateFormatter dateFromString:jan01String]; NSLog(@"originalDate: %@, jan01String: %@, jan01Date: %@", originalDate, jan01String, jan01Date);output:2016-07-14 15:44:49.723 NSDateFormatterTests[5414:1537640] originalDate: 2000-01-01 00:00:00 +0000, jan01String: 01/01/00, jan01Date: 12099-12-31 22:00:00 +0000
Posted
by
Post not yet marked as solved
1 Replies
529 Views
I'm a newbie to Launch agent and daemons. Now I'm currently developing the remote desktop (like VNC) application for macOS with Objective-C and my application supported macOS versions are 10.6 and later. I have created a pre-login agent and it will launch my application when login window open.I am using CGEventPost to simulate keyboard and mouse events in user logged-in sessions. But it's not working in pre-login window (global login window)Citrix, LogMeIn are providing the remote controls in Pre-login window too. How are they doing it?Any help will be highly appreciated.Please refer the code//For KeyboardCGEventRef keyEvent = CGEventCreateKeyboardEvent( NULL, keyCode, down ) ;CGEventPost( kCGHIDEventTap, keyEvent ) ;CFRelease( keyEvent ) ;//For MouseCGEventRef event = CGEventCreateMouseEvent(eventSource, eventType, mouseLocation, mouseButton ); CGEventPost(kCGHIDEventTap, event);CFRelease(event);//Pre-login launch agent<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>Label</key> <string>my app label</string> <key>LimitLoadToSessionType</key> <string>LoginWindow</string> <key>RunAtLoad</key> <true/> <key>WorkingDirectory</key> <string>My app directory</string> <key>ProgramArguments</key> <array> <string>app absolute path</string> <string>service</string> <string>myservice</string> </array> <key>KeepAlive</key> <true/></dict></plist>
Posted
by
Post not yet marked as solved
5 Replies
6.8k Views
My Info.plist looks like that:<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>UIDeviceFamily</key> <array> <integer>1</integer> </array> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>MinimumOSVersion</key> <string>8.0</string> <key>CFBundleDisplayName</key> <string>***</string> <key>CFBundleIdentifier</key> <string>***</string> <key>CFBundleVersion</key> <string>1.3</string> <key>CFBundleIconFiles</key> <array> <string>Icon@2x.png</string> <string>Icon.png</string> <string>Icon-60@2x.png</string> <string>Icon-Small@2x.png</string> <string>Icon-Small.png</string> <string>Icon-Small-40@2x.png</string> </array> <key>CFBundleShortVersionString</key> <string>1.3</string> <key>UIPrerenderedIcon</key> <false/> <key>UIMainStoryboardFile</key> <string>LaunchScreen</string> <key>NSContactsUsageDescription</key> <string></string> <key>NSCalendarsUsageDescription</key> <string></string> <key>NSMicrophoneUsageDescription</key> <string></string> <key>NSAppleMusicUsageDescription</key> <string></string> <key>NSSiriUsageDescription</key> <string></string></dict></plist>But I get the demand from the I Tunes Store to add an entry for NSContactsUsageDescription, NSCalendarsUsageDescription, NSMicrophoneUsageDescription, NSAppleMusicUsageDescription, NSSiriUsageDescription.So I have no idea what i'm doing wrong.Thanks a lot for help...
Posted
by
Post marked as solved
3 Replies
11k Views
Specifically, when using URLSession.dataTask:..., I get this error:dnssd_clientstub ConnectToServer: connect()-> No of tries: 1 dnssd_clientstub ConnectToServer: connect()-> No of tries: 2 dnssd_clientstub ConnectToServer: connect()-> No of tries: 3 dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:7 Err:-1 Errno:1 Operation not permitted [] nw_resolver_create_dns_service_on_queue DNSServiceCreateConnection failed: ServiceNotRunning(-65563) Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSUnderlyingError=0x60800005bae0 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, NSErrorFailingURLStringKey=https://<URL snipped>, NSErrorFailingURLKey=https://<URL snipped>, _kCFStreamErrorDomainKey=10, _kCFStreamErrorCodeKey=-72000, NSLocalizedDescription=A server with the specified hostname could not be found.}This error only occurs in my Xcode project, and not anywhere else in my system (e.g. Safari), so I don't think this is a problem with my DNS setup (I did try changing DNS addresses to make sure). The URL I'm requesting works in other applications, so it isn't a server problem either.I don't observe any UDP/TCP traffic using Wireshark when URLSession.dataTask: runs.Does anyone have any thoughts as to what the issue is?Xcode 8.110.12.2 Beta (16C41b)Thanks
Posted
by
Post not yet marked as solved
2 Replies
1.1k Views
Is there any particular reason why a WKWebView instance set as the contentView of a NSWindow would not display web content when the window is displayed using the runModalForWindow method of NSApplication?If I display the window using the showWindow method of NSWindowController, it displays correctly.If I replace the WKWebView instance with a WebView instance, the web content displays correctly whether the window is shown modally or not.In all cases I am calling loadRequest: in windowDidLoad.Bruce
Posted
by
Post not yet marked as solved
3 Replies
607 Views
Hi,I'm trying to figure out how an NSViewController can check if it was presented as a popvoer, so it might by notification and delegate pattern inform observers and let delegate act upon disappearing of the popover by overriding viewWillDisappear method.So far I've with this solution:- (BOOL)isPresentedAsPopover { id popoverFrameClass = NSClassFromString(@"NSPopoverFrame"); id ourSuperViewClass = [[[self view] superview] class]; return [ourSuperViewClass isEqualTo:popoverFrameClass]; }I've found that when a NSViewController is presented as popover programmatically via presentViewController:asPopoverRelativeToRect:ofView:preferredEdge:behavior: method its view gets embedded in a NSPopoverFrame class view.Which seems to be part of a class cluster pattern, hence it's a private class. I don't like this kind of solution, knowing that in future this could change etc.Is there a better way to do that, rather than setting boolean property value in the View Controller when presenting it programmatically as a popover?
Posted
by
Post not yet marked as solved
1 Replies
265 Views
My app observes NSWorkspaceActiveSpaceDidChangeNotification and set wallpaper on the active screen. But I see there is no way to distinguish between spaces on a screen. I'm not sure if I have read the docs thoroughly. I would like to know if it is possible to tell which space is active for the active screen.
Posted
by
Post not yet marked as solved
1 Replies
779 Views
I have created an iOS Share Extension, and am returning a simple NSItemProvider: let item = NSItemProvider(item: "A Response" as NSSecureCoding, typeIdentifier: kUTTypeText as String) let extensionItem = NSExtensionItem() extensionItem.attachments = [item] self.extensionContext!.completeRequest(returningItems: [extensionItem], completionHandler: nil)But in the host app, in the completionWithItemsHandler, completed is true, yet, returnedItems is nil. activityController.completionWithItemsHandler = { (activity, completed, items, error) in print("\(items?.count)") }Yet, returning the exact same response in an ActionExtension, the result reached the host app. Does a Share Extension not send its response back to the host app? The docs would suggest otherwise: https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Share.html#//apple_ref/doc/uid/TP40014214-CH12-SW1Sample project: http://gofile.me/2oQIB/s9zxCa58g
Posted
by