objective-c

Accessing an NSMutableArray in another class from a class

What would be the best way to access an NSMutableArray and its associated objects from within a different class? Should I write accessor methods to return the components I need or can I somehow assign a pointer to it from within the class I need to access it from? ...

iPhone Objective-C Placement of NSNotifications

I have a fairly complex iphone application that has many asynchronous processes occurring. To deal with this I'm making heavy use of NSNotification Center. My question is what is the "best practice", if such a thing exists", for registering the notifications? Right now they sprinkled through my code in a hap-hazard way. I'm about to ...

Trying to use C++ in an iPhone app

I am trying to use c++ in an iphone app. I added the line #include <cstring> in one of my files. I get "error: cstring: no such file or directory". What do I need to do to get it working? My understanding is that gcc is being called, but not g++. How can I change that, or what flag can I add to force gcc to compile c++? ...

Best way to split a string into tokens skipping escaped delimiters?

I'm receiving an NSString which uses commas as delimiters, and a backslash as an escape character. I was looking into splitting the string using componentsSeparatedByString, but I found no way to specify the escape character. Is there a built-in way to do this? NSScanner? CFStringTokenizer? If not, would it be better to split the string...

[objective-c] getting integer from string with formatted number

I have a string representing a number, and I want to convert it an NSInteger. The problem is, that the string is formatted with thousand separators: "1,234" when using [value intValue], I get 1 as the value. Is it because it thinks the thousand separator is a decimal separator? (my locale uses comma as decimal separator and a space o...

Is it possible to access the raw data in Core Data for a Transformable attribute

I have an image field of type transformable and a typical ImageToDataTransformer class. 99% of the time that's perfect and great shortcut, but just occasionally I find myself transforming the managed object back to NSData (knowing that if it wasn't for the ImageToDataTransformer I would have got NSData in the first place). As these oper...

object crashes Application

Hi out there. i got an NSArray which gets filled in the init Method of my UITableViewController. i use this object in "didSelectRowAtIndexPath" for pushing another tableviewcontroller. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ablogSingleCatTableViewController *singleCatTableViewCont...

Avoiding compiler warnings when doing message forwarding

I created a class that wraps a UITextView and adds some ui elements. I want the new class' API to be identical with UITextView, so I use message forwarding (listing below) to relay messages between the wrapped text view and the delegate. The irritating thing is that the compiler issues warnings for method invocations on instances of my ...

If-Statement for String/Int

Hi, my if clause always runs into the else statement? Whats the fault? NSLog([[category objectForKey:@"id"] stringValue]); // Traces 15 if ([[category objectForKey:@"id"] stringValue] == "15") { result.isExternal = YES; } else { result.isExternal = NO; } thanks for helping ...

NSTimer with a menu bar app

I'm working on a simple timer app, and I've created a NSStatusItem with a menu and I have some NSTextField labels that updates the timer labels (http://cld.ly/e81dqm) but when I click on the status item the NSTimer stops (and stops updating the labels)..... how can I get around this problem? EDIT: here's the code that starts the timer:...

Error Undefined symbols: "_compress" with Image Upload Class

Hi, im want use this Class http://stackoverflow.com/questions/125306/how-can-i-upload-a-photo-to-a-server-with-the-iphone to Upload an image from my iPhone App to my Webserver. Ive Copyd the header and main file and added "#import "EPUploader.m"" to my ViewControler where i call the EPUploader Method. Error Message is: Ld build/Relea...

NSDictionary - Printing Array

Hi, This site is great I'm getting alot of replies , so I have tried to code what I had problems with before here it is NSMutableArray *sort = [NSMutableArray arraywithArray:[dic allValues]]; for(NSString *s in sort){ [Purchases appendString:[NSString stringWithFormat:@"%@",s]]; } textview.text = Purchases; The output's ord...

How to disable the highlight control state of a UIButton?

I've got a UIButton that, when selected, shouldn't change state when being touched. The default behaviour is for it to be in UIControlStateHighlighted while being touched, and this is making me angry. Suggestions? ...

Is BOOL read/write atomic in Objective C?

What happens when two threads set a BOOL to YES "at the same time"? ...

Enum or typedef with types

I'd like to create a simple object that I can access like this: myobject.floatValue1 = 1.0; myobject.floatValue2 = 2.0; It shouldn't have anymore than the two properties. Is it possible to create an enum or typedef with such a simple structure. Or must I create a class? ...

Animate setContent of an NSWindow

Hi there. In the past I've been successfully able to fade in an NSWindow using the following code; if (![statusWindow isVisible]) { statusWindow.alphaValue = 0.0; [statusWindow.animator setAlphaValue:1.0]; } CAAnimation *anim = [CABasicAnimation animation]; [anim setDelegate:self]; [statusWindow setAnimations:[NSDictionary dic...

HTTP Requests in Cocoa.

Is there a good tutorial or something similar for making HTTP requests and JSON in cocoa? As I'm playing around with the Simplenote API. ...

Add integers from 5 UITextFields to a UILabel in Cocoa Touch

I'm trying to sum the integers from five UITextFields and post them to a UILabel. This is the code I have tried, but it doesn't work properly. The number that shows up in the label is not the sum of my textfields. I have also tried to post to a textfield instead of a label, with the same result. No errors or warnings when I build. int ...

iPhone: Executing code Just Once at Initiation of Object

Hey everyone, this is an EXTREMELY beginner question, and I'm somewhat ashamed I don't know it already: How can I execute code just once at the implementation of my object? I have an object that's of a subclass of UIView I want some code to be executed as soon as everything kicks off, but I'm only able to get code to be executed in resp...

Store static Content on iPhone?

Hi there, I was wondering what is the best way to store static content for my app. E.g. a list of products (name, photos, price, url). Maybe s.o. can direct to a good tutorial? thanks. ...