objective-c

NSNumber crashing program

HI, Due to formatting issues, I'm converting floats to NSNumber in my iPhone app. Although it generates proper strings it crashes program after releasing the object. I wrote simple program as console app for Mac OS X and same problem occurs. Can anybody advise how to solve that? Here is the code sample. All 3 messages are written to l...

What is near, far and huge pointers?

Can anyone explain me these pointers with a suitable example ... and when these pointers are used? ...

What is causing memory leaks?

Hi, What is causing the leaks in this code? I really cannot understand it. On thes lines: 1: NSMutableArray * days = [[NSMutableArray alloc]init]; 2: [dic setObject:days forKey:key]; 3: [days addObject:value]; The whole method: -(void) addValueToDictionary: (NSMutableDictionary *) dic withValue: (NSNumber *) value forKey: (NSString *) ...

how to control the user in iphone

I have the application which allows the users to play songs. I want to allow the user to listen to a maximum of three songs before forcing the user to log in. The user should be able to listen to these three songs during the course of the day, but if they still haven't logged in they should no longer be able to listen to these songs. Ho...

NSApplication endSheet: has no effect

Ok, this is really stumping me: I create a modal sheet on a window as -(IBAction) login: (id) sender { [NSApp beginSheet:loginWindow modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil]; } and try to remove it with -(IBAction) loginWindowCancelPressed: (id) sender { debugLog(@"cancel")...

What is the best way to display a list using Cocoa?

The iPhone has the UITableView for displaying lists and information, what is the best way to display the same type of lists using Cocoa for an OSX application? I'm trying to convert one of my iPhone apps to the desktop using Cocoa, but having a hard time finding the same type of list view. Thanks for any help in advance! ...

Objective-C classes composition

I'm trying to clarify some of Obj-C classes composition issues. I have 3 classes: Car, Control, and Wheels. Car class initializes Control and Wheels classes. I was going to create a simple test iPhone application containing a UISlider and UILabel. When UISlider value is changed, a message must be sent (I was going to send it from Contr...

Can't run Cocoa UnitTests because of Garbage Collector disabling

I'm trying to add some UnitTests to a bunch of Cocoa Legacy code. I created a Unit Test Bundle, and added all source and frameworks needed, but the build fails with this message: 2010-08-26 16:07:18.074 otest-x86_64[64675:903] The test bundle at /Users/giordano/application/build/Release/UnitTest.octest could not be loaded because its...

Run a task in the background of an iPhone App

I want to be able to load data from my API server in the background of my iPhone app. How do I achieve this? ...

Customised UIView compliation error message

Here is a code fragment #import "MyCustomView.h" @implementation MyCustomView -(void) drawRect:(CGRect)rect { NSLog(@"Help"); CGContextRef myContext = [[NSGraphicsContext // 1 currentContext]graphicsPort]; .... Then at 1, I encountered this error message: NSGraphicsContext undeclared (first...

How do you create a formatted string like the following in Objective-C?

I'm a newcomer to the iPhone world. (Previously, I've developed for android.) I've got this code in one of my Android apps: String body = "<Item type='Customer' id= '"+id+"' action='delete'/>"; What's the same in Objective-C? ...

iPhone OpenCv build issues

I'm trying to build open_cv on the iphone. I'm a pre-compiled version of it from http://github.com/niw/iphone_opencv_test and am seeing the following build errors... "_cvCvtColor", referenced from: +[PFFaceDetection CreateIplImageFromUIImage:] in PFFaceDetection.o "_OBJC_CLASS_$_PFImageEffects", referenced from: ob...

Garbage collection eats status item

Hello I turned on garbage collection (objective-c 2.0) and the image for the status item disappeared when I restarted my application.  I am manually memory managing the image and status item.  This application works normal when garbage collection is off.  Is there a way to make the garbage collection not collect specific variables or sho...

Object allocations instrument on iphone

Hey All, I have problem with the way I treat the memory management in iphone..please please help me..I am running out of ideas..I tried to play with the below method but it started leaks when I am trying to allocate the strings for the objects (for example allocation for sid,first_name etc)..I can't figure out how to do..and this is the...

NSRunLoop is receiving a strange selector; possible race condition tomfoolery?

I've got some threads doing heavy work while my main thread handles the UI stuff. The threads callback to the main thread at times to update a progress bar. All in all, it's not that stable. I've fixed problems relating to the logic, but one in particular persists. I've got some code that acts like a stop button, meaning that the thread...

Statically-typed Objective-C Object seems to think it's a NSCFArray instead

I'm trying to pick up Objective-C but ran into a roadblock experimenting with the object syntax. When I try to call a method from a class I've defined, though, I'm getting this as output. 11:29:19 $ /Users/rsmith/Projects/Objective-C/Expedition/a.out; exit Loading command-line wrapper...load successful! 2010-08-26 11:29:19.070 a.out[161...

Scrolling text with wrapping on iPhone

Hi, is it possible to make text scroll horizontally and wrap when finished? Automatically scrolling like a NYSE ticker. And is there a method that could get called on the re-wrap, so I could, for example, refresh the news feed? I heard you can do this in Three20 but I'm not sure of the class / implementation. Cheers! ...

How to use Json parser/generator for objective-c

Hi all, Does anyone have a tutorial of how to use this Json framework. It basically allows parsing and generating of json but I have no idea how to use it! I need to build up a Json request send it to the webservice and then parse the response. ...

Does NSLog'ing something alter its retain count? Because I am slowly going insane here.

Further to this question: http://stackoverflow.com/questions/3576724/nsrunloop-is-receiving-a-strange-selector-possible-race-condition-tomfoolery - where it was discovered that a UIGestureRecognizer was being deallocated and then receiving a message, I printed out the address of one of my GRs in order to see if it was the one being repor...

Getting iOS outlets wired in InterfaceBuilder

I'm new to developing in iOS and succesfully ran through a tutorial on how to create and connect outlets in a Mac OSX Cocoa App. However, when I try to follow the same process for my iPhone app, I keep hitting walls... (Apologies for the lengthy example- please bear with) Project A: In XCode: Create new Mac OSX Cocoa Application Cre...