objective-c

iPhone file IO in pure c/posix style

Hi, is there a way to write files to the iphone file system using only pure c code and some posix like api? I only found some Objective-C/Cocoa stuff out there and I think that I can't just mix some Objective-C code snippet into the .c file. ...

Appname-info.plist

I am about to upload my App to the Apple store but i have no idea about info.plist any idea about it will be great. or let it without any changes. ...

Objective C [object release]

I'm looking at someone else's code, but it appears to RELEASE object VIDEO but then continue to use it. Now from my understanding of Object Oriented Programming languages, once it's released, it should be dealloc'd from memory... I can't see how it has any references...but I'm assuming that's the reason it's OK. Seems like a strange th...

Cocoa Touch retain object returned from NSUserDefaults?

I have a NSArray object retrieved from the standard user defaults object, [NSUSerDefaults standardUserDefaults]. I want to save this array as a member variable of another object and use it for the lifetime of this object. I'm not sure if the array from NSUserDefaults is an autorelease object. Should I retain the array? ...

2 touches drag problem

Hello all, i used the code below to handel the touches in my app and i used for loop in touchesBegan to handel 2 touches in the same time but the problem is if the user make a drag with 2 fingers just one work can i make the 2 works properly ? code: - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -(void)touchesMoved:...

Orientation in iPhone

Hi, I have been working for iphone for about like 1 month and i want to know that is their any method by which we can set the orientation of the components, like when the device is turned in landscape left or right or in portrait mode then the components must set their view accordingly. Please help me out regarding this Thank You ...

Best practice for checking data types at runtime objective-c

Hi all, I have JSON data being provided to my application but unfortunatly it is not very well formed. Sometimes I am getting String representations of numbers when I am expecting numbers. For some reason some values may have a prefix of whitespace. What is the best way to deal with this? Currently I am forced to check the types vi...

printing int with specified nr of digits

I am trying to print out a 5 digit number as follows: int rdmNr = arc4random()%100000; NSLog(@"%i",rdmNr); I always would like to have 5 digit numbers. Example outputs should be: 00001 10544 00555 78801 But with the previous code I would also get 1 or 555 without 0s. I also tried %5i, but the I just get more white spaces. ...

HttpRiot other linker flags issue

Hi everyone, i'm developing a game which already uses httpRiot framework to communicate with a server. Now i'm also trying to add an ad-mob library but i'm getting issues with the other linked flags, if I put the -all_load flag my ad-mob service crashes, and if I take it off HttpRiot crashes, anyone knows if there is a way to make HttpR...

How to profile an app that uses IPC

I have implemented part of activity monitor using NSTAsk and NSPipe. This is very slow. Is there any other method to implement it ? And also tell me how to get samples of prcesses. ...

dealloc without alloc?

How is it possible that I have a dealloc without having an object allocated? Please see the log when switching from the MAIN view to the RSSItem view. The 0xdd5adf0 memory gets deallocated, but I can't find where it was allocated. Thanks for any input. ps: self (null) is from trying to print one of the properties of the 0xdd5adf0 obje...

[Objective-C] How to use stringWithContentsOfURL:encoding:error: ?

Hi guys, I am trying to use initWithContentsOfURL:encoding:error: like this : NSURL *url = [[NSURL alloc] initWithString:@"http://my_url.com/my_file.xml"]; NSError *error = nil; NSString *my_string = [[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; I get a empty my_string variable. I tried th...

Caching an entire web page on the iPhone

I am considering caching an entire web page locally on the iphone, i.e. I want to provide a url and have the device download all the assets automatically. ASIHTTPRequest offers a cache, but as far as I understand it will only cache whatever url you feed it. I wonder if anyone has implemented a caching mechanism that will parse the downl...

Objective C / Object Orientated Pointers

Hello world.. I have been playing with objective C a little and am finding it a great language.. Coming from C# i found pointers a little hard but now i understand the concept and how to use them.. ie: MyObject* x = [[myObject alloc] callinitializer]; which create a new object on the heap and a pointer on the stack.. but can someb...

Printing directly to Ethernet printer using 'raster mode': need basic guidance

I've stumbled across a problem way beyond my area of expertise, and I don't have a mentor to turn to for help with this. I have a receipt printer I need to interface with through an iOS app. The printer is located on the same network as the device(s), so I can address it through supported "Line Mode commands" What I'd like to do is kee...

Creating a custom loading screen on iPhone

I'd like to create a View/Window that performs some inital loading in my application. I tried something like this: StartWindow *start = [[StartWindow alloc] initWithNibName:@"Start" bundle:nil]; self.startWindow = start; [start release]; [window addSubview:startWindow.view]; And in the viewDidLoad event inside StartWindow for the t...

How to write Objective-C Blocks inline?

I am trying to implement a binary search using objective-c blocks. I am using the function indexOfObject:inSortedRange:options:usingComparator:. Here is an example. // A pile of data. NSUInteger amount = 900000; // A number to search for. NSNumber* number = [NSNumber numberWithInt:724242]; // Create some array. NSMutableArray* array = ...

Reflection in Objective-C (iPhone)

I want to populate [MyClass class] from a JSON string. I use json-framework to get the NSDictionary, and it's dead easy to instantiate and setValue: forKey:... on my data object. But for more complex data objects with classes as members of MyClass, ie: MyOtherClass *classNoTwo I tried with Class test = object_getClass(myClass.cl...

cpp file #include causing errors, @class not

In an iPad app im using a thirdParty cpp file that acts as a controller for some UI functionality; its wired up with IB and a @class definition is all i need. However now I'm trying to set a delegate on the cpp file and therefore have to include it in the implementation of my viewController. including the cpp header in my implementatio...

How can I easily redirect the console output in a NSTextView?

Suppose you have the code of a Cocoa app which logs its own messages through NSlogs and printfs to the Console output. My goal is to redirect all this output into a separate NSWindow in a NSView. How can I achieve this in a way that minimizes the amount of code to rewrite makes it possible to revert back maximizes the reuse of written...