How to show alert pop-up in in Cocoa on macOS?

You can use NSAlert in cocoa. This is same as UIAlertView in ios. you can pop-up alert by this NSAlert *alert = [NSAlert alertWithMessageText:@”Alert” defaultButton:@”Ok” alternateButton:@”Cancel” otherButton:nil informativeTextWithFormat:@”Alert pop up displayed”]; [alert runModal]; EDIT: This is the latest used method as above method is deprecated now. NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:@”Message text.”]; … Read more

Does NSView have anything analogous to UIView’s setNeedsLayout/layoutSubviews methods?

As of OSX 10.7: – (void)layout is equivalent to layoutSubviews There is now an identical setNeedsLayout. Override this method if your custom view needs to perform custom layout not expressible using the constraint-based layout system. In this case you are responsible for calling setNeedsLayout: when something that impacts your custom layout changes. You may not … Read more

Core Data -existingObjectWithID:error: causes error 133000

The problem is that NSManagedObjectID you pass is temporary. You can check it by calling NSManagedObjectID‘s isTemporaryID method. From docs: Returns a Boolean value that indicates whether the receiver is temporary. Most object IDs return NO. New objects inserted into a managed object context are assigned a temporary ID which is replaced with a permanent … Read more

How to let NSTextField grow with the text in auto layout?

The method intrinsicContentSize in NSView returns what the view itself thinks of as its intrinsic content size. NSTextField calculates this without considering the wraps property of its cell, so it will report the dimensions of the text if laid out in on a single line. Hence, a custom subclass of NSTextField can override this method … Read more

How do I make an NSView move to the front of all NSViews

Here’s another way to accomplish this that’s a bit more clear and succinct: [viewToBeMadeForemost removeFromSuperview]; [self addSubview:viewToBeMadeForemost positioned:NSWindowAbove relativeTo:nil]; Per the documentation for this method, when you use relativeTo:nil the view is added above (or below, with NSWindowBelow) all of its siblings.

Cocoa Keyboard Shortcuts in Dialog without an Edit Menu

Improving on that CocoaRocket solution: The following saves having to subclass NSTextField and remembering to use the subclass throughout your application; it will also enable copy, paste and friends for other responders that handle them, eg. NSTextView. Put this in a subclass of NSApplication and alter the principal class in your Info.plist accordingly. – (void) … Read more

Mac App Store Receipt Validation Code?

It is hard to provide a generic solution for Mac App Store receipt validation, mainly because this is a very sensitive piece of code that must be hard to bypass (cf. Apple documentation). These GitHub projects are very good starting points to learn about what steps must be performed in receipt validation: NPReceiptVerification ValidateStoreReceipt AppReceiptParser … Read more