Questions tagged [cocoa]

30712 questions
1

votes
1

answer
36

Views

Which replacement method is called when editing an attributed string?

NSMutableAttributedString defines two string replacement methods: func replaceCharacters(in range: NSRange, with str: String) and func replaceCharacters(in range: NSRange, with attrString: NSAttributedString) I have created a subclass of NSTextStorage which in its turn is a subclass of NSMutableAt...
Mischa
1

votes
1

answer
20

Views

Presenting NSViewController in MacOS app works fine until I archive the build

After an App Store rejection for a MacOS app, i've come across a very strange thing happening. I have an NSViewController in my storyboard with a storyboardID set. I call this from a button with the following code: NSViewController *loginViewController = [self.storyboard instantiateControllerWithIde...
Darren
-1

votes
3

answer
2k

Views

How to add a corner radius to a uiviewcontroller

I noticed that in snapchat they rounded their corners of a uiviewcontroller. I was wondering how could I replicate the same thing accross all view controllers. Would I declare it in the app delegate or in each individual view controller. Could someone please show me how to do it. I have an example i...
Rosalind
1

votes
3

answer
1.7k

Views

NSScrollView with fixed background texture

I have an IKImageBrowserView that is the document view of an NSScrollView. How can I set a background image (a texture) so that the background remains fixed when the user scrolls. I have tried a variety of things but either they just don't work or it doesn't remain fixed. I have tried making the IKI...
Jonathan.
1

votes
2

answer
3.4k

Views

iOS - How to set the date and time programatically

I have a requirement in which we need to programatically set the date and time (or sync the time) from a server. I did some research on this but did not get a concrete answer. Was just wondering if anyone has done this in iOS? Is there any Apple documentation which says we cannot do this?
Anand Vyas
1

votes
2

answer
297

Views

How do you get the Finder “Kind” for a file?

I want to get the Finder 'Kind' for a file. For example, for a file 'foo.css', I want the string 'CSS style sheet'. So far, I'm doing something like this: NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: filename]; NSString *utiType; NSError *error; BOOL success = [fileURL getResourceValue: &ut...
John
1

votes
2

answer
1.4k

Views

dispatch_async block not called

I've run into an issue I had never seen before. I never thought it might exist. I'm using DFCache library and in a certain moment dispatch_async using global queue doesn't execute block. - (void)cachedObjectForKey:(NSString *)key completion:(void (^)(id))completion { if (!key.length) { _dwarf_cache...
Andrey Chernukha
1

votes
1

answer
854

Views

macOS XPC Service not starting

I have a desktop Swift app with a single XPC service that has stopped working. I've managed to get it working once since, but it is back to being broken. I've tried reducing the code to the simplest case but it feels like there is a factor I don't understand. Init Code: connection = NSXPCConnection(...
Mike Bedar
1

votes
1

answer
608

Views

NSTableView Bindings doesn't work mac OS Swift

I'm trying to use cocoa bindings with nstableview and I have some problems with bind of parameter value of textfield: I'm using this code, class: class Person : NSObject { var givenName:String var familyName:String var age = 0 var lol = 0 override init() { givenName = 'given' familyName = 'family'...
Igor Voitenko
0

votes
0

answer
3

Views

NSOpenPanel under Sandbox - Access All Files inside User Selected folder

My sandboxed macOS app imports image files selected by the user via an NSOpenPanel modal window, as is customary. At first, I configured the panel to canChooseDirectories = false, and set the allowedFileTypes property to NSImage.imageTypes. So far so good. Using the app, I realized that the images I...
Nicolas Miari
0

votes
0

answer
2

Views

User send me a .IPS crash report for my iOS app, how do I make it readable or symbolicate it?

All the tutorials online seem to discuss symbolicating crashes from your own device that you can plug in, but I had a user with a weird crash so I had them send me the crash file from their iPhone, and they sent me a .IPS file. It seems unsymbolicated, how do I symbolicate it and make it readable?
Doug Smith
1

votes
1

answer
735

Views

NSControl with multiple actions

I'm trying to create a complex custom NSControl that must be able to send more than one message. For example, on mouse over in must send an action, and on mouse drag in must send another action. I can't understand how to wire a target to a control and make the control sends whatever message to the...
MatterGoal
1

votes
1

answer
320

Views

How to render a layer hosting NSView to file

Is there any way to render a layer hosting NSView (as it appears onscreen) to a PDF or bitmap file without implementing each CALayer's –drawInContext: method (or similarly, each layer's delegate's -(void)drawLayer:inContext: method)? I just want the contents of the NSView exactly as they appear wi...
chris.bennett
3

votes
3

answer
652

Views

WKWebView - content not fitting after magnification

I’m experiencing a problem with a WKWebView on setting the magnification property. I expecting the content to resize to fit like it does in Safari. But I can’t achieve this. When setting the magnification to a value less than 1.0 is the following. The extra space is not used and a margin occurs....
Jan Linxweiler
1

votes
0

answer
9

Views

Animate self-sizing NSTableView row height

I have a project that uses self-sizing table view cells. I'd like to animate when the height of a cell changes. NSTableView's noteHeightOfRows(withIndexesChanged:) will do this for view-based cells, but only when providing the height explicitly in the delegate's tableView(_, heightOfRow:) method. Wh...
smr
1

votes
2

answer
958

Views

Nil returned from a method that is expected to return a non-null value

I'm implementing UIKeyInput, UITextInputTraits, and UITextInput and with that I'm required to implement: - (NSArray *)selectionRectsForRange:(UITextRange *)range { return nil; } However, in analyzing my project I get: 'nil returned from a method that is expected to return a non-null value'. What wo...
Ser Pounce
1

votes
2

answer
608

Views

UIScrollView Subviews not expanding to fill width (Autolayout)

I'm using the following code to constrain a view to the left and right anchors of a parent UIScrollView. Despite the right anchor and the left anchor being set to the ScrollView's left and right anchors, the view does not expand to fill the scrollview. Note: The gray background in this image is the...
orion
1

votes
1

answer
43

Views

Is there a way to detect if a macOS app running is from the Mac App Store or not?

I have this app of mine that is distributed on the Mac App Store and outside it, from my own site. I need to detect, at run time, what version is running, so I can do some decisions inside the code. Is there a way to detect that? How can I differentiate that? Is there a way to know if the app is sig...
SpaceDog
1

votes
1

answer
41

Views

What's the name of the OSX look up “Dialog / Pop-up”?

I'm trying to find the name and the corresponding API documentation for the tooltip-like dialog that opens up when you click 'Look Up...'
CosminM.
1

votes
1

answer
425

Views

When Do Blocks Cause Retain Cycles When Using Self?

I am having some memory issue leaks in my app and I am wondering if blocks may have to do with it. I have read that using Self in a block can cause retain cycles, however I have read conflicting information on when this occurs. From what I understand, doing something like this: dispatch_async(dispat...
benjih555
1

votes
1

answer
573

Views

Sandbox entitlement to script iTunes via NSAppleScript

I'm trying to script iTunes from NSAppleScript in my Cocoa app in order to add a file to the library. In my entitlements file, I added the following: com.apple.security.scripting-targets com.apple.itunes com.apple.itunes.library.read-write I then call the AppleScript like this: var error: NSDictiona...
beeb
1

votes
1

answer
367

Views

Objective-C: Show A window popup from background Cocoa application

I have created a COCOA application that runs in user background and keeps on check for a notification. When there is a notification then the application should display a popup window. How I am running the application in background? I have set Application is background only Using the above method th...
Vikas Bansal
1

votes
1

answer
68

Views

How to put a case statement into {}

Okay So I am working on a project and trying to make it neat and visibly understandable where everything is is difficult. To my knowledge Xcode doesn't have an Indent Guide, but something is does have is the ability to collapse the code inside {} like this: This can work for any {}. I want to make m...
grahamcracker1234
1

votes
2

answer
63

Views

Any bugs or changes in NSTimer with OC?

I'm testing NSTimer with OC and Swift. When I write with OC, here is something I don't quite understand: is it REQUIRED to add the timer to the NSRunLoop after the timer is inited? If not required, why can't it be invoked in a loop even if I set the repeats to YES? Here is my code, I just init a tim...
xianlong
1

votes
2

answer
362

Views

Any performance difference between removeObject vs removeObjectAtIndex on a single object?

Will removeObjectAtIndex be faster/more efficient in removing a single object from a NSMutableArray than removeObject? I am assuming so since the search should be faster. If a significant difference is to be expected for large arrays, I will keep track of the indices. Hence, the questions.
Smart Home
1

votes
1

answer
599

Views

Cannot set view for NSOpenGLContext

(Sorry in advance for the seemingly large amount of code here) I'm trying to create a window with an OpenGL context with Cocoa, but I'm finding that I am unable to set the view property of the NSOpenGLContext that I create. I cannot simply use an NSOpenGLView, since I need to interface with a C++ dr...
KFox
1

votes
1

answer
68

Views

How to open a NSAlert in awakeFromNib? (taking care of the window animation)

I get a problem with a NSAlert that is created in -awakeFromNib method. The xib window animation takes some time, and the alert is crated and added to the app too early (so it is detached from the window). If instead I delay the method call everything works fine, but I guess that's not the correct w...
aneuryzm
1

votes
1

answer
307

Views

OSAtomicIncrement64 x class property… what is the advantage?

If I understood correctly, OSAtomicIncrement64 should be used to increment a variable atomically. What is the difference/advantage of using one or the other of the scenarios below? SCENARIO 1 @interface MyClass : NSObject { __block volatile int64_t variable; } and OSAtomicIncrement64(&variable); i...
SpaceDog
1

votes
1

answer
149

Views

What did -mountedLocalVolumePaths and -mountedRemovableMedia do in Obj-C

Currently working on porting some deprecated code from on old OS X project I've inherited and haven't been able to find any documentation on what these methods did. [ [ NSWorkspace sharedWorkspace ] mountedLocalVolumePaths ] ] [ [ NSWorkspace sharedWorkspace ] mountedRemovableMedia ] ] I do know tha...
mosquito242
1

votes
1

answer
466

Views

NSMutableAttributedString Italic and Bold do not work at the same time

I need to italicized and bold an NSMutableAttributedString, I tried some combinations but only one attribute works. [attributedText addAttributes:@{NSFontAttributeName:[UIFont italicSystemFontOfSize:14], NSFontAttributeName:[UIFont boldSystemFontOfSize:boldTextFontSize]} range:range3]; and [attrib...
Kalmdoun
1

votes
1

answer
513

Views

UIGraphics Memory Leak

There seems to be a memory leak in this code, but I cannot find it. What am I doing wrong? Specifically, lines 1 and 2 add to the apps memory usage, and only the memory from line one goes away when the context is ended. UIGraphicsBeginImageContext(imageView.bounds.size); [imageView.layer renderInCon...
mntruell
1

votes
1

answer
141

Views

Option key in Cocoa Emacs not entering accented characters

Using an international keyboard with TTY emacs works fine for entering characters: alt-e + a enters á alt-i + a enters â etc The problem is that in Cocoa Emacs that same doesn't hold true. These keys get interpreted as emacs commands. I tried to unbind these keys globally, even unbinded they don't...
jbssm
1

votes
2

answer
544

Views

NSWorkspace sharedWorkspace runningApplications causing memory leak; alternative option?

I'd like to know whether anyone has a suggestion for an alternative to using runningApplications, as something like the following appears to be leaking memory: https://openradar.appspot.com/24067155 https://github.com/bradjasper/NSRunningApplicationMemoryLeaks - (void)applicationDidFinishLaunching:(...
x74353
1

votes
1

answer
175

Views

NSWorkspace iconForFile: how to detect the generic folder icon?

I am querying some existing folder's icon. I am trying to do: [[NSWorkspace sharedWorkspace] iconForFile:targetPath] and for the generic icon I am getting: ( , , , , , , , , , , , , , , ) How can I distinguish whether a folder has the regular 'generic' icon, or a custom made one?
Nili
1

votes
3

answer
627

Views

Selector don't getting notification from NSNotificationCenter (iOS)

I am sending a notification from a class inherits from NSObject using NSNotificationCenter. The notification should be sent to 2 viewController but it's being sent just to one of them. My Code: fetchFromParse: -(void)sendAllStores { [[NSNotificationCenter defaultCenter]postNotificationName:@'getStor...
FS.O
1

votes
1

answer
51

Views

Why action is perform multiple time after loading is finish and why it queuing all the events?

While loading when we click on back button or any cell of the table the action is called multiple times after loading is finish.Here the the code snippet that what i'm doing when I start the loading and stop the loading. +(void)showLoader_OnView{ APP_DELEGATE.window.userInteractionEnabled = NO; [MBP...
Sourav Mishra
1

votes
1

answer
57

Views

Undo and Redo in core data cocoa application - is this normal behaviour?

I have core data cocoa application. I was trying different ways to enable the undo and redo option using bindings, and I couldn't find a way how to do it. So I make 2 IBActions and I have now the following code: (only the code relevant to the question is posted due the simplicity) - (void)windowDidL...
user2417624
1

votes
1

answer
108

Views

Safe mutation and usage of readonly property value in Objective-C APIs

Consider a C++ API like const T* foo(). This clearly documents the supported mutability and use of the API: OK, we'll let you look at T, but please don't change it. You can still mutate it, but you have to explicitly use const_cast to indicate your intention to not follow the API. A good portion of...
1

votes
1

answer
713

Views

dequeueReusableCellWithIdentifier returning the same cells for different indexPath

using dequeueReusableCellWithIdentifier works for the first 7 cells and then it randomly starts to reuse the cells from 1-7 for 8-14 and so on... However it should be creating new cells as they dont exist yet. This is my code- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: N...
user3781268
1

votes
1

answer
417

Views

Multiple enum value in swift

I want to create an enum value like view.autoresizingMask = [UIViewAutoresizing.FlexibleBottomMargin, UIViewAutoresizing.FlexibleHeight] I can not figure out to to design the enum to accept multiple variable. I want to design the below. enum ActivityType: Int { case Event = 1 case CommentOnEvent =...
Tapas Pal

View additional questions