cocoa

floatValue for CGFloat

Hi Everyone: I have a NSSlider that is attempting to convert a regular float into a CGFloat. The code that I am using: CGFloat testing = [mainSlider floatValue]; However this simply makes the testing variable "0.00" when I attempt to log it. NSLog(@"%f", testing); Does anyone have any ideas as to why this would happen? Thanks fo...

Resolving a remote $HOME directory via FTP/SFTP.

In Objective-C, NSString has a method called stringByExpandingTildeInPath This method will take a string like "~/Documents" and resolve it to "/Users/Nick/Documents". The "~" tilde is resolved to the home directory of the current user of the machine the program is running on. Now my question is this... I am writing a little FTP/SFTP ...

Can I start a thread by pressing a button in a cocoa interface and keep using interface while thread runs?

I have a Cocoa interface. When I press a button I want to process some data, but I want to keep using the interface while it's working. I guess the only solution is NSThread. Now will there be a locking mechanism preventing me from returning from an IBAction method if it spawns a thread? ...

How to mix right hand expression types in NSPredicateEdditor

Hi, I'm currently designing a predicate editor and want to use for some fields different right hand types. Unfortunately you can only select one type like numbers, dates, constants, etc. What I want is dates AND constants. I have tried to use a second row template but this is not allowed for the rules editor. Any ideas? Thanks. ...

Problems with Drag and Drop in an NSOutlineView.

The problem I have is that I have an NSOutlineView with Drag and Drop (see the bottom of post for code to make drag and drop work), it works, but when I drag one row into another row the dragged row becomes a child but it also stays where it was as a parent, and when I delete either row both of them get deleted. To show you what I mean,...

NSCollectionView not updating subviews on data change

I have set up an NSCollectionView through Interface Builder. My prototype view contains a progress indicator and a text field. I have set up the bindings so that my "task" object maintains the value of the progress indicator and the text field value. It all works okay when I add new objects to the collection (via [NSCollectionView newIt...

Programmatically Activate NSMenuItem

When you press the keys for an NSMenuItem keyboard shortcut on Mac, the menu itself highlights to indicate that an action in that menu has been activated. If you are not familiar with the effect try it now by selecting some text and while pressing CMD-C, watch the Edit menu. It will flash blue to indicate you activated a shortcut for an...

Error drawing text on NSImage in PyObjC

I'm trying to overlay an image with some text using PyObjC, while striving to answer my question, "Annotate images using tools built into OS X". By referencing CocoaMagic, a RubyObjC replacement for RMagick, I've come up with this: #!/usr/bin/env python from AppKit import * source_image = "/Library/Desktop Pictures/Nature/Aurora.jpg"...

Working with AFP in Objective-C/Carbon

I'm working on an app that needs to transfer files to an AFP volume -- ideally, it wouldn't mount the volume on OSX, since it's really unnecessary. Looking over the AFP protocol stuff, I came across an old Carbon header file "afpDatastream.h". This used to be in the framework "AppleShareClientCore", however it's no longer there (on Leo...

Store specific interactions with Core Data

I was reading the docs on core data looking to speed up my search. I found the following and was slightly confused as to what it meant: The SQL store, on the other hand, compiles the predicate and sort descriptors to SQL and evaluates the result in the database itself. This is done primarily for performance—databases are mu...

How can I refresh core plot without returning from a method?

Hi. I have a cocoa interface that uses core plot. When I press a button in the interface, a plot is drawn. I wanted to create a sequence of graphs by calling the plotting method multiple times along with calls to sleep() in between. But it seems that even though the call to reload data is made that nothing happens until the function ex...

is there a way to pause an NSTHread indefinitely and have it resumed from another thread?

Seems these are the only methods to put a NSThread to sleep * sleepForTimeInterval: * sleepUntilDate: Would it be bad practice what I am asking? ...

How to get BOOL from id

I'm calling valueForKey on an object. This returns an id which I tried to cast to a BOOL (because I know the value is a BOOL). But XCode gives the following warning: "warning: cast from pointer to integer of different size..." So what I ended up doing was this: BOOL value = [[NSNumber numberWithInt:((NSInteger)[managedObject value...

Core Animation or OpenGL for simple iPhone game

I am writing a simple game that animates a ball image quickly across a background image. Would Core Animation/Quartz be sufficient for this scenario? I don't really want to learn OpenGL ES if it is not going to provide any substantial benefit in this one off project. ...

NSString - Convert to pure alphabet only (i.e. remove accents+punctuation)

I'm trying to compare names without any punctuation, spaces, accents etc. At the moment I am doing the following: -(NSString*) prepareString:(NSString*)a { //remove any accents and punctuation; a=[[[NSString alloc] initWithData:[a dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES] encoding:NSASCIIStringEncoding] a...

Cocoa app - security issue [SOLVED]

Hello! I've a question about a good way to protect a bit my cocoa app from piracy! I know that this is impossible! So, in my app I've an isRegistered() method that run every time the user launch the app! This is called in the applicationDidFinishLaunching: App delegate ... so if this method return true, the app continue to execute the ...

How to store dates without times in Core Data

I've been trying to find a sensible way of storing daily data using Core Data on the iPhone. My app receives data in csv format, with a date but no time: date, cycles 2009-08-01, 123 2009-08-02, 234 2009-08-03, 345 2009-08-04, 456 When this data is stored, there should only be one record per day. I figured the best thing to do was cr...

Changing default font size for NSTable/NSOutlineView

I dont quite understand how to change (decrease) the font size for the text in my NSOutlineView. The default text is larger than most applications use for their font size. There is some heirachical thing where you dont set the font directory but you inherit from something "above" the table or outline view. Is there anywhere that neatly...

Filtering A Tree Controller.

I have now nearly figured out how to Filter a NSTreeController, to do this I have sub-classed NSManagedObject and added some code to my App Delegate, I have also bound my NSSearchField to the filterPredicate of my App Delegate but I think I need to connect my NSTreeController and NSSearchField in some way to make it work. Below I have po...

Using toolbar & views on Cocoa

Hi, I'm getting started with Mac apps development and trying to figure out some things. I want to create an app with tabs like Selectable Toolbar from BWToolkit (I try it but still has lots of bugs). And when I click one of its buttons, I want to display a different view. What are the classes that I need to use? The Interface Builder...