objective-c

Easiest way to populate array from custom class?

Say you have a class Person (with name, age, etc), and an array called PeopleArray which has several individual Person's. What's the easiest way of extracting each Person's name (for instance) and putting it into an array. Psuedocode is: nameArray = every Person's name, from the array PeopleArray ...

Is there a library / framework that allows to program a Carbon application using C++ classes?

Is there any library that allows to create a Carbon application using C++ classes? ...

Cocoa - Method to count the characters in a text field?

I'm pretty new to objective C started a few days ago... I want to count all the chars in a text field. Could [textField length] be useful at all and how do I use it? ...

iOS4 - Background audio with iPhone Simulator

I unsuccessfully tried to implement a playback audio that continues to play in background by setting the UIBackgroundModes property and by activating an audio session as Joshua Weinberg suggested, but it doesn't work on the simulator and I have no chance to test on a device with iOS4. I read about of a possible issue with the simulator, ...

How to clean spaces in a NSString

Hi, I would like to reduce the number of spaces between two words in a NSString (Objective-C/iPhone dev) to only one. Do you know some method that could do that ? Exemple : Before cleaning : "Hi,       my   name       is                Tom." After cleaning : "Hi, my name is Tom." Thanks ...

Releasing while notifying

Hi there!, I have an object id currentObject; which I want to pass through notification. The problem is I don't know how to release it correctly and the memory management documentation is driving me crazy. I am doing it like this right now: [[NSNotificationCenter defaultCenter] postNotificationName:@"MessageReceived" object:nil us...

How do I get the int ASCII value of a character in Cocoa?

How do I get the ASCII value as an int of a character in Cocoa? I found an answer for doing this in python, but I need to know how to do this in Cocoa. ( I am still a noob in Cocoa). Python method: use function ord() like this: >>> ord('a') 97 and also chr() for the other way around: >>> chr(97) 'a' how do I do this in Cocoa?...

iPhone SDK: Memory issues in releasing a UIViewController with UITextField

Hi all, I've some memory issues with a view controller that contains a text field. Brief summary: Clicking on a button my application modally presents a UIViewController (that I will call "VC1"). From VC1 the user can optionally open (using pushViewController) a UITableViewController ("VC2") and turn back. From VC1 the user can optional...

How do I make an array of CGFloats in objective c?

So I'm working on a simple iPhone game and am trying to make a local high score table. I want to make an array and push the highest scores into it. Below is the code I have so far: CGFloat score; score=delegate.score; NSInteger currentindex=0; for (CGFloat *oldscore in highscores) { if (score>oldscore) ...

Objective-c animation block doesn't seem to fire

I have a method in my UIView subclass "Card" to dismiss an instance by fading its alpha from 1 to 0. I do a similar thing when I add the card to the superview and it fades in fine. But when I call fadeAway, it just disappears immediately. The presentation code is in my controller class. Here is my Card.h and Card.m #import <UIKit/...

Programming a USB Device on a Mac

I'm updating some old old code (that works for now, but is using OpenTransport, so um... no) that interfaces with a USB scanner. I THINK I understand how IOUSBDeviceInterface and IOUSBInterfaceInterface are supposed to work, but I can't seem to get information about the pipes. I have a method which takes: (IOUSBInterfaceInterface **)int...

reloading table view works just by scrolling outside the visible area.

Hi, normally, the way to update a tableView is calling self.tableView reloadData (or setNeedsDisplay), but my (visible) tableView doesn't reload by calling this method. My context is, that I've got a Navigation-Bar and a TableView and by clicking a button on the Navigationbar, the method "aktualisieren" starts. This method also works ...

Releasing Objects When Do and When dont I have too

Here is some code I have in my app that I DIDNT release. When I try to release I get a Program received signal: “EXC_BAD_ACCESS”. exception and the app crashes. If I dont try to release it the app runs fine. Do I need to call a release message on these objects? Any idea what could be going on here? NSString *sA = legA.text; ...

How can iPhone Nibs be Unit Tested using Logical Tests?

Unit Testing View Controllers seems to be very important part of iPhone Development (see this Article). This, however, requires initializing the Controllers from a Nib, which I found impossible to do properly in a logical test. Loading Resources from a Bundle (see this Question) in a logical test works fine. Even loading Nibs is possibl...

Why is my program receiving EXC_BAD_ACCESS in _class_isInitialized() during an objc_msgSend()?

Final Update: Turns out the fix to this problem is a depressing one. Go into the .xcodeproj directory inside your project, and remove the <username>.mode1v3 and <username>.pbxuser files. That fixed it. Boo, Xcode. I'll start this off by saying that it's not your usual retain/release bug. It just started happening on a development bra...

How Do I sort an NSMutable Array with NSNumbers in it?

I'm trying to make a high score table, and suck at arrays in objective c (actually, in general objective c is challenging for me), so I can't figure out how to sort. I'm trying to do something like this (speudocode, I'm writing this in actionscript style because I'm more comfortable with it): highscores.addObjecttoArray(score) highscore...

How do I launch an application on system startup? (Mac OSX, Cocoa)

I have a program that runs only in the toolbar (w/ time/date, spotlight, etc.) and I want to put an item in the preferences to allow the user to select whether to start my application on the system startup or not. I'm currently lost on where to find some documentation on this. Any links or short code snippets would be much appreciated. T...

Is there a way to launch Voice Control programatically on the iPhone?

Is there a way to launch Voice Control programatically just like you can launch Safari? If so, how? ...

How do I stream video from the iPhone

Is it possible to stream video directly from the iPhone? Is there any undocumented way to do it? Or am I missing something? ...

@selector and other class (Objective-C)

Hi, Inside an object I use NSMenu's addItemWithTitle:action:keyEquivalent: to create NSMenuItems. The problem is that I wish to call a method on another object as action. The action: part takes an @selector as parameter and I don't know how to use this to call methods on other objects. I could create a method inside the object creating ...