cocoa

Fast User Switching Hides CALayer

I have an GUI cocoa application that is automatically started when the computer is woken from sleep. The application runs in multiple users accounts at the same time and is sometime launched in a user account that is not the current user being displayed on screen (i.e. the active console user). This is where the problem arises. I have a...

How to get a time since string from a NSDate object?

Basically, I'm getting a date time string from an API, and I want to show in the app that this activity happened '5 hours ago' or '3 days ago', and so on... I am currently trying to get the NSTimeInterval from [NSDate timeIntervalSinceNow] method. And then converting the time interval to NSDate again using [NSDate dateWithTimeIntervalSi...

Flatten CALayer sublayers into one layer

In my app I have one root layer, and many images which are sublayers of rootLayer. I'd like to flatten all the sublayers of rootLayer into one layer/image, that don't have any sublayers. I think I should do this by drawing all sublayers in core graphics context, but I don't know how to do that. I hope you'll understand me, and sorry for...

float is getting mangled when passing between methods (typecasting problem?)

I'm having trouble passing a float value from one object to another. It appears to be fine in the first method, but in the second its value is huge. I assume this is some kind of a problem with my typecasting, because that's the thing I understand the poorest. Help is greatly appreciated! In my game controller, I do this: float accurac...

Data Detectors in Cocoa

I want to add a data detector in an NSTextField / NSTextView like in Mail (e.g. date, email, URL, etc). Does anyone have an idea how to do this ? I think I saw it in TextEdit's source code but when I checked it was 2005's version and I can't find the new source code. Alex ...

Using Global Variables to communicate values between classes

So my simple idea is to create an app that allows the user to report their location's latitude and longitude coordinates via email. You tap the button, the email screen comes up via the MessageUI framework, the To, Subject, and Body fields are already pre-entered, all that's needed is for the user to hit "send". My problem, is that I n...

How to delete NSBezierPath

H, I have an NSBezierPath that I created and I called -stroke on it. How do I remove/delete it from the view without deallocating the object. Thanks - Rebecca ...

Force all capitals in NSTextField (Cocoa)

Hi, Is there a way to force capitals in a NSTextField? I want to create a text field for typing in Post Codes, and I want all post codes entered to use capital letters. e.g. N1 3ET instead of: n1 3et Also, I am using a regular expression, which only accepts capitals (I know very little about regular expressions, so I'm not keen on mod...

How do I Drag and Drop a '.txt' file in obj-c

I'm trying to write some absolutely barebones code where I can drag a plain 'dot.txt' file onto an NSWindow and read in the data (and nothing fancier than that), but all the examples I've been able to find use images and NSViews etc.. Apple's 'Dragging File Contents' section in its "Drag and Drop Programming Topics for Cocoa" documentati...

Passing CoreData content to a NSViewController

I've started to move to using NSViewControllers and I can't for the life of me figure out how to get content from a CoreData entity to a TableView (for example) through a NSViewController? ...

How can I pop up Webkit's Web Inspector from my WebView object programmatically?

How can I pop up Webkit's Web Inspector from my WebView object programmatically? I succeed to enable Webkit's Web Inspector on my WebView. It's working well, and now I can pop it up by clicking "Inspect Element" on context menu. And I want to do this with my push button. But I couldn't find a proper way to do this. My DOM knowledge is 1...

Basic Cocoa Bindings: Toggle a boolean from menu in IB

I'm just getting started with Cocoa Bindings and while I've read through much of the documentation, I'm still struggling to implement a basic feature, making me question wether I'm doing it wrong or perhaps it's just not possible via IB. Goal: Have a menu item called "Toggle visibility" toggle the state of a Boolean property in my appl...

Compile Error with: switch, "expected expression before"

Hello, Cut to the chase I have recreated my problem as it is fairly self explanatory. this complies without error: switch (n) { case 1: NSLog(@""); NSString *aStr; break; default: break; } this compiles with error and it's only missing the NSLog(): switch (n) { case 1: NSStri...

NSFormatter used with a NSPopUpButton

I have a NSPopUpButton whose content values are bound to an NSArray of NSNumbers. The NSPopUpButton correctly displays the array of numbers in it's popup-menu. However, when I change the selected value, I receive a message: HIToolbox: ignoring exception 'Unacceptable type of value for attribute: property = "tempo"; desired type = NSNumb...

NSTableView and displaying sort image in column header question

Hi, I have a NSTableView with 3 columns. I can sort using any of the colunms by clicking on the column header. Here is my issue though: I am presorting the array and then loading it in NSTableView so the initial TableView is already sorted by the values in one of the 3 columns. Now when I click on the column headers, i can resort and the...

How to disable resizing of the subview of NSSplitView in Interface Builder?

I've created in Interface Builder a NSSplitView with two subviews. I want the left-side view to have fixed width. I've tried to define autosizing rules for both subviews but the left subview still changes width on window resizing (split view fills up a window). May be that caused by NSSplitView's Autoresizes Subviews property? (I can't u...

refreshing NSTableView with new data multiple times

Hi, I have an NSMutableArray and I load my tableview from it. Now I have a Button in the UI which kinda lets the user refresh the data that goes into the array multiple times. And everytime there is new data in the Array I want to refresh the tableView. Just doing [tableView reloadData] after updating the array seems to bring up the be...

Drag-and-drop pasteboard data

I'm trying to write some simple code to drag-and-drop the contents of a text file onto a window. With some help from an earlier post and an Apple example I've now got the basics of drag-and-drop up and running. Unfortunately however, Apple's sample code deals only with images. Can anyone please tell me how I'd modify their "pasteboard" ...

Can a NSFormatter be used with a NSPopUpButton?

This question is similar to this one: http://stackoverflow.com/questions/821363/how-do-i-use-an-nsformatter-subclass-with-an-nspopupbutton As mentioned in that question, it seems like the 'formatter' used by the cell of a NSPopUpButton doesn't seem to work. I'm wondering if this is expected, or if there is actually a purpose to setting ...

Any cocoa source code for AES encryption decryption?

Hi all, I am searching for some cocoa code on AES encryption and I did some google search for it. I found this very useful link - http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html. So I tried it but it did not work for me. Can anyone suggest me some useful link or source code which can help me...