objective-c

char to ascii - Objective-C

i want to convert char array to ascii, i started trying with NSString, characterAtIndex ( failed due to lack of knowledge about manipulating unichar ) creating a char array and passing it to a NSString using stringWithCString ( failed due to lack of knowledge about encoding ) now at the end i am convincing myself using normal char arr...

Checking for empty NSSet?

Is there a way to check if a set is empty? NSMutableSet *setEmpty = [[NSMutableSet alloc] init]; // Code to do things... // Check for empty set? [setEmpty release]; gary ...

Switching a view

Hello! I have a problem with switching views in an iPhone application. I have the source code of "Beginning iPhone 3 Development" (http://books.google.com/books?id=TcP2bgESYfgC&printsec=frontcover&dq=beginning+iphone+3+development#v=onepage&q=beginning%20iphone%203%20development&f=false) - chapter 6 - Multiview Applicati...

force application to terminate in iPhone

I am developing an iPhone application which is completely based on web data. If it is not connected to the internet, the application is of no use. So, I want to terminate the application when connection is not found. NSURL *tmpURl=[NSURL URLWithString:[NSString stringWithFormat:@"%@search.php",[iGolfAppDelegate getServerPath]]]; ...

How to use the USB/HID port with objective-c under a Mac environment?

Hi, I am having big trouble to communicate through USB, from a Mac to an external HID device. The hardware has been proven fine when running under the Windows XP platform, but I can't find a GOOD exemple of programming the HID with Cocoa / objective-C. Several exemples are available in the Apple center, but they are either poorly docume...

What describes nil best? What's that really?

Currently I understand it as a kind of "empty object". But what's it really? ...

CLLocationSpeed Issue

I'm trying to get my code to return the velocity of the device in miles per hour with the following: double speed = newLocation.speed; NSString *speedyspeed = [NSString stringWithFormat:@"%d", (speed*2.2369)]; yourSpeed.text = speedyspeed; the "speed*2.2369" is supposed to correct for the fact that the speed is returned in meters/seco...

UIWebView didFinishLoading fires multiple times

I have some code that needs to run after the a UIWebView finishes loading a document. For that I've set the UIWebView's delegate to my controller, and implemented the webViewDidFinishLoading method. This gets called multiple times, depending on the type of page to load. I'm not sure if it's because of ajax requests, requests for image...

Finding out if a Window is being Dragged

I am trying to write a program that requires to know if a window is being dragged (moved around). The catch is that it's not the program's window, but rather any window in the OS (eg. Safari, iTunes, Adium, TextMate, etc.), and what program it belongs to I was thinking AppleScript would be a potential way to do this, but there doesn't s...

Randomly disappearing struct

Hi, I've created a Objective-C class to interface with PostgreSQL using libpq. It mostly works but I have one small problem - the connection seems to disappear randomly. This class is set to open a connection when a window is opened and close that connection before the window closes. On the init code of the window I open the connection...

Difference between Foundation Framework and Core Foundation Framework?

I try to get the hang of it, but for now both seem the same thing to me. However, Xcode allows to create an Console App with choice of using "Core Foundation" or just "Foundation". Maybe someone can point out the differences. ...

Action performed by UIViewController in UITabBar and Switched Back to Original View

In have a UITabBarController with 3 view controller subviews. The default subview for the app is viewOne (with viewControllerOne). The other two are viewTwo and viewThree with the ordering in the UITabBar as expected. My objective is to have an action be done when viewTwo is selected in the UITabBar while viewOne is active. The viewTwo...

How to sort NSMutableArray using sortedArrayUsingDescriptors ?

Hi, I have a question about sorting NSMutableArray. I can use sortedArrayUsingDescriptors: method to sort an array with objects. For example I have an NSMutableArray of places where I have an attribute frequency (int value) and I want to sort descending on frequency but I don't now if I how to use it correctly. What do I put as a k...

Why does -isMemberOfClass: not work here?

NSMutableArray *arr = [NSMutableArray arrayWithCapacity:3]; if ([arr isMemberOfClass:[NSMutableArray class]]) { NSLog(@"YEP!!"); } else { NSLog(@"NO!!"); } I get always "NO!!" in console. I tried with Array, NSNumber, NSString. All of them don't seem to work. That's strange. As I get it from the docs, this method should return...

What exactly is a so called "Class Cluster" in Objective-C?

I was reading that NSArray is just such a thing. Sounds heavy. I have 7 really fat books here on my desk about Objective-C, Cocoa and C. None of them mention Class Cluster at all, at least I can't find it in the Index at the back of the books. So what's that? ...

How to split objective c function definition?

Hi, I have a really long objective c function definition, and would like to split it into multiple lines to make the function more readable. Let's say I have this definition: -(id) initWithBsType:(NSInteger)buysell AccountCode:(NSString *):c_acc_code password:(NSString *)password exchangeCode:(NSString *)ecode productCode:(NSString *)p...

Objective C concept explanation

I have the following code: - (void)setItem:(Todo *)newItem { item = newItem; } Why is it that I can't do - (void)setItem:(Todo *)newItem { self.item = newItem; } ? I have item declared in my header file but I get a EXC_BAD_ACCESS error? Item is also not synthesized. The method is meant to be a custom setter. Thanks! ...

When should I use a prefix on Objective C classes?

According to Apple, two to three letter prefixes should be used when naming classes, protocols, functions, constants, and typedef structures. Does this include classes which are not intended to be part of a framework, simply used internally in an application? I realize this is relying on other developers that develop frameworks yo...

Game crashes on the actual iPhone but simulator? memory problem?

Hi everyone I have built my first game using Cocos2D. It worked fine on the simulator. But when it runs on the actual iPhone, it crashes. I don know why. Thought it was memory leaks, so i tried to detect, but no leaks found. I tried to increase and decrease frame rate, neither both succeeded. Anyone experienced please help me out. I am...

Can't get NSTableView to display data.

Hi! I see there are a lot of questions about this, but nothing helped me to get this work. I have a nib with a NSTableView with three columns (with the right identifiers set) and a class named ShortcutsTableController. In the nib I have a NSObject with class value ShortcutsTableController. I also connected the NSTableView to my controlle...