cocoa

How to run OCTest from command-line, not XCode

XCode 3.1.2 using built-in OCTest unit testing. I'm getting a crash when unit tests run. I want to run w/ a few extra environment variables (MallocCheckHeapStart, MallocCheckHeapEach, for example). I'm a beginner with this and can't figure out how to run my app's OCTest unit tests from the command-line. Or alternatively, to convince ...

NSImage vs. CIImage vs. CGImage?

When should I use each? ...

iphone: creating image without allocating new memory

the pointer data if pointing to some image generated by an iphone application. Does anybody now if using CGBitmapContextCreate make a copy of this data or does it use the image "in place"? Ideally, I'd like to reuse the information in data* and not create any additional copy of this image. void* data = <my data>; CGColorSpaceRef color...

How to display a raw YUV frame in a Cocoa OpenGL program

Hello everyone, I have been assigned wit the task to write a program that takes a sample raw YUV file and display it in a Cocoa OpenGL program. I am an intern at my job and I have little or no clue how to start. I have been reading wikipedia & articles on YUV, but I couldn't find any good source code on how to open a raw YUV file, ext...

Including Objective C++ Type in C++ Class Definition

I've got a project that is primarily in C++, but I'm trying to link in a Objective-C++ library. I have a header that looks something like: CPlus.h: #import "OBJCObject.h" class CPlus { OBJCObject *someObj; }; CPlus.mm: CPlus::CPlus() { someObj = [[OBJCObject alloc] init]; } When I import the Objective-C++ header into my code...

NSSortDescriptor for comparing CLLocation objects in Cocoa/iPhone

I have an array of CLLocation objects and I'd like to be able to compare them to get distance from a starting CLLocation object. The math is straight forward but I'm curious if there is a convenience sort descriptor to go about doing this? Should I avoid NSSortDescriptor and write a custom compare method + bubble sort? I'm usually compar...

Ideal way to single-instance apps on the Mac

On Windows, it's common practice to create a named mutex and use the presence of that to determine that an instance of a given app is already running. This has its drawbacks, but mostly works. I can think of a ways to do this on the Mac: named pthread mutexes enumerate running processes and look for one that matches create and lock a ...

Running Process listing

Hi , Is there any way to list all the processes currently running in Cocoa.I am developing an application in cocoa,which needs to check whether that application is already running or not before launching..Looking for a solution..... ...

Check whether application already running

Hi all, I am developing an application in cocoa,which needs to check whether that app is already running at start up.If already running then i need to quit the new instance ..Is there any way to do this..Looking for a perfect solution ...

Resources for Unit Testing Cocoa Applications

I'm looking into unit testing and TDD for a Cocoa desktop application and I'd like to find some code examples. I am aware of Chris Hanson's excellent articles, but I'd like to crowdsource finding some examples of actual tests in a code base. ...

Objective C - Remove last character from string

In Objective C for the iPhone, how would I remove the last character of a string using a button action. ...

Making a Checkbox Toggle The Dock Icon On and Off.

How would I make a checkbox hide the dock icon if it was checked? I have made a checkbox toggle a menubar item but how would you do it with the dock icon? Looking for some code to do this. Thanks! ...

How to keep model & controller separate from a CALayer based UI?

I'm trying to re-implement an old Reversi board game I wrote with a bit more of a snazzy UI. I've looked at Jens Alfke's GeekGameBoard code for inspiration, and CALayers looks like the way to go for implementing the UI. However, there is no clean separation of model and view in the GeekGameBoard code; the model is the view, which makes ...

Reset NSToolbar back to default configuration

I programatically create an NSToolbar in my application. I just added a new button to the toolbar and added that button to the default configuration of the toolbar. When I run my application the new button is not shown by default. That's because I already have been using the program and I already have a plist file in which this new butto...

Database Results in Cocoa

Hi everyone. I am creating an application that has to interact with server data and then display the results from a database accordingly. I am writing the client side app in Cocoa. Example: A user logs on to a web application. They have some options for filing a web report. Choices: single line and multiple line. They can choose ho...

Cocoa network streams and the garbage collector.

I'm writing a little network application in Cocoa, using objective-c 2.0. I have the garbage collector enabled in required mode (-fobjc-gc-only). When I run the code most of the time it works like a charm. But sometimes it just crashes without warning, and gdb launches. I'm as yet unable to get any useful info from GDB. The code is as fo...

External Data File for Unit Tests

I'm a newbie to Unit Testing and I'm after some best practice advice. I'm coding in Cocoa using Xcode. I've got a method that's validating a URL that a user enters. I want it to only accept http:// protocol and only accept URLs that have valid characters. Is it acceptable to have one test for this and use a test data file? The data fil...

Where to put local variables

I have a view who's methods are called by the accelerometer updates in the view controller. I need more than one method to use and change certain variables, for example one method initializes the variable and another updates their value with each accel update. I know if they were only used on one method I could declare them inside that...

Objective C - Adding characters at specific parts of a string

I have made a quadratic equation solver for the iPhone and when the text box is clicked, my own custom keypad appears. I have a button that changes whether the number is positive or negative. Right now I what happens is that when the button is pressed (0 - current value of text) is what is displayed in the text box, so if the number is p...

Why can't I seem to unarchive objects in an iPhone app that were archived by an OS X app?

I'm writing an iPhone app that is mainly centered around grid patterns, so I have a Pattern class which contains an NSMutableArray of NSMutableArrays. This class implements NSCoding, and it seems the following code works just fine in my iPhone app: GridPattern * pattern = [GridPattern patternWithWidth:8 height:8]; [pattern setValueAtCo...