objective-c

Encoding custom classes using yajl-objc

Summary. Based on some benchmarks, I chose yajl-objc for my iPhone JSON parser. I was testing it with an arbitrary custom class (one NSNumber and two NSString properties). If I created an NSDictionary with key-value pairs matching the class properties, I could encode the dictionary with [dictionary yajl_JSON]. When I tried directly encod...

Anyone done an Objective-C Xode version of Osherove´s TDD Kata "String Calculator"?

Always trying to code better and I am interested in doing TDD for Objective-C and Xcode. Do you know any post that implement something like Roy Osherove´s "String Calculator"-Kata Update: trying to find out how to speed up TDD on iOS ...

Using a UIButton as an Accessory View for a UITableCell

I have run into an interesting bug where it appears that when you select a UITableCell it changes all of it's subviews to their highlighed state. This includes my accessoryView which is a UIButton which obviously I only want highlighted when the user presses like a normal button. I have a friend who went as far subclassing UIButton to ...

Memory Leaks when using NSPropertyListSerialization

This method in my class reads a previously created plist, but when it does NSPropertyListSerialization leaks all over the place. NSDates and NSCFStrings, mostly. Any suggestions on what I can do to prevent this? - (id)readPlist:(NSString *)fileName { NSData *plistData; NSString *errorA; NSPropertyListFormat format; ...

xCode command-line > foundation problem

Hi, I'm trying to set up a command-line > foundation "hello world" project. (as written in the book 'learning objective C for mac') ...When I select 'build & run' with the default settings for this project I get 4 errors, without modifying any code!? errors: stdarg.h: no such file or directory float.h: no such file or directory xmmin...

How to make a Subview pop-up from an action in UITableviewController

Hi everyone, I would like to pop-up a subview pop-up from one of the actions performed by a button placedon a tableview controller. I initially added a sub-view(initally hidden below the screen) and later want to animate it to animate and pop-up. Here is the code for the button action -(IBAction) finalShareVerse: (id) sender { NS...

Problem with string sharing over AppDelegate-Class

I'm sharing my string over the AppDelegate-Class: SpeakersAppDelegate *mainDelegate = (SpeakersAppDelegate *)[[UIApplication sharedApplication] delegate]; [mainDelegate setShareText:xmlString]; And get the string back from the AppDelegate-Class: SpeakersAppDelegate *mainDelegate = (SpeakersAppDelegate *)[[UIApplication sharedApplic...

Correct way to instantiate NSDictionary/NSArray in init without extra retains

I have numerous classes that use the various NSDictionary/NSArray collection classes as ivars but often I run into the problem of my collection class getting released before the containing class is released. This seems to happen mostly with the collections classes and not with another model class (ie classes that I either created separ...

How to listen on a network port in Objective-C

Hi! I am trying to make an application for iPhone that can listen for traffick on a specific network port. A server on my network is sending out messages (different status messages for devices the server handles) on a specific port. My problem is that when I make a thread and makePairWithSocket I block the port for others who want to s...

iPhone SDK Managing Memory for Multiview app

I have an app that programmatically creates labels and text fields based on the contents of a text file. Whenever the view controller is loaded, it creates text fields and labels that are different each time. My problem is I need to clear out the labels and text fields without releasing the view controller since I need to keep track of t...

How would I intercept HTTP traffic in a Cocoa application?

Ok so what I want to do is create a background agent that monitors http traffic to/from a certain application and performs actions when there are requests and responses to a certain website. Is there a good way to do this in Cocoa? I'd like to avoid using really low level sniffing and/or requiring root access to do this (admin access is ...

UISlider to represent the color spectrum

I have a UISlider that is supposed to update the color of a textlabel. Now I want the user to be able to choose between all colors in the spectrum (sort of all anyway). I was thinking of using this UISlider to represent the colors and when dragging the slider the value/color changes. I know the spectrum is not sequential like: [0,0,0].....

Problem with UIWebView

Hi, I am trying to launch an external safari when I click on a hyperlink in UIWebView but in my case nothing happens. If I try to include target as blank and skip the UIWebView delegate method it launches the safari within the same view..please guide me friends how to open an external browser when tapped on a link in UIWebView..here is ...

Difference between a double in c# and objective-c when converting to string

I am in the process of migrating the awesome c# geocode framework http://code.google.com/p/geocoordconversion/ to objective-c however I've noticed a subtle difference. There is a line in the code which does the following: int retVal = Math.Abs(allAfterDecimal).ToString().Trim('0').Length - 1; Now I have written matching test scrip...

Populating CoreData with a for-loop creates memory error -am I doing it wrong?

Howdy, I have an issue with populating coredata from an XML load. From my limited knowledge it appears to be a memory issue, I am looking squarely at the managed object constructer in the for loop in the pseudo-code below! We can assume 'myManagedStore' is a valid coredata object with an NSSet of "managedObjects" and that 'myNSSetOfIt...

iPhone/iPad - Loop Background Music?

Hi First time doing this, hope you can help. What the best way of playing background music for my iPad game? 1b. How do I do this? Whats the best format of having that music file in for playback? Will this this song happily play through the entire game, no interruptions when changing view? How can I loop this music? Thanks. ...

Objective-C Strings

I am reviewing code that makes the following call: id<PLResultSet> results = [sqliteDatabase executeQuery:@"select * where id=?",Id]; sqliteDatabase is an instance of PlausibleDatabase (from GoogleCode, I gather). The code works, but I don't understand it. Specifically, how does this section work? @"select * where id=?",Id Is the...

Making multiple service calls on iPhone app initialization

I need to make multiple asynchronous service calls in the application:didFinishLaunchingWithOptions: method from my application delegate in order to retrieve some data from a service to be used across various controllers in my app. I have control over the service, and I've designed the API to be as RESTful as possible, so I need to make ...

Cannot save prepopulated sql database to core data sql database: managedObjectModel not found

my program needs to take a prepopulated sql database and then save the records to the app's database. Unfortunately for some reason the application quits in this method in the application delegate: #pragma mark - #pragma mark Core Data stack - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel_ != nil) { ret...

NSString: how to use substring in a loop?

Hi, sText is an instance variable of type NSString. No properties are involved. The loop below is supposed to get the first character of sText and store that char in sCurrentCharacter. Then the rest of sText should be reassigned to sText. This goes on until the string has been eaten up. (I left out all the code which actually does some...