objective-c

How to read coordinates from file in iPhone

I have a text file that contains a list of coords to construct a path: 123,44 124,67 178,85 This file is included as part of the bundle. The question is how can I read the points from this file. In C++ there's fscanf, what about Cocoa? ...

Calibrating code to iphone acellerometer and gyro data

I'm concepting an iPhone app that will require precise calibration to the iPhones accelerometer and gyro data. I will have to simulate specific movements that I would eventually like to execute code. (Think shake-to-shuffle, or undo). Is there a good way of doing this already? or something you can come up with? Perhaps some way to gene...

NSXMLParser vs KissXML vs TouchXML which one is memory efficient ?

Hi, I have a large XML file ( around 1mb ) . i want to ask that if i parse the XML with NSXMLParser or KissXML/TouchXML. which will take less interim memroy ?? ( the memroy took during parsing ) . ...

iPhone app crashes after loading it from background

I have an app that crashes when i try to load it after it has been put in the background. The first few times i put it in the background and relaunch it by multi-tasking (i.e double clicking the home button and getting the app in foreground) it works fine. But if i keep putting it in background and keep re launching it after a few ti...

iPhone optimized code to do accordion style(expansion/collapse) ??

Hi, Could someone share me some good idea of doing an accordion style(one which can expand and collapse on touchesEnded or some button) of display for text ?? I already have done in some manner...but lookin forward for a better version..would be nice if it could be animated too... ...

Is it possible to update the UITableCell's height through cellForRowAtIndexPath?

When dealing with UITableViewControllers, is there a way to set the height of an individual table cell other than this method: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; Basically what I am trying to do is insert a block of text into a table cell that would have a variable height. T...

how to generate random number from 0.5 to 1.0

How to Generate the random number from 0.5 to 1.0 . ...

How to add an integer value into NSMutableArray?

NSMutableArray * val; val = [[NSMutableArray alloc] initWithCapacity:15]; /*int outlineWidth = barOutlineWidth; int outlineHalfWidth = (outlineWidth > 1) ? outlineWidth * 0.5f : 0; */ for ( Bar * obj in values ) { // calcualte the bar size float value = [obj value]; float scale = ( value / maxValue ); // shift the bar to t...

How to sync the audio file or text file or image into iTunes programatically in iphone.

Hi Guys, I want to sync the file into iTunes, I do not have any idea of this how to implement. I want the file which i had need to sync with iTunes programmatically. Can you suggest any idea how to implement this. Thank you very much in advance, Madan Mohan. ...

notification for any window creation/destruction under mac OS X

Hello; I would like to be notifier each time a new window is created or destructed, at system level (not only the ones belonging to my application) Do you have any pointer to achieve this? Thanks in advance for your help, Regards, ...

Objective c - float returning wrong value

Hi I'm using objective c and trying to output a value from a function. Apparently I am doing something wrong because I'm receiving an incorrect value. This is my code: -(float) getAngleBetween { float num = 0.0; return num; } and I'm calling it as follows: float *theAngleBetween = [self getAngleBetween]; NSLog(@"Angle.. = %f", the...

How does [UIAlertView show] work?

I want to do something similar to UIAlertView, ie - without reference to any UIView or UIViewController, present a UIViewController on top of all windows using presentModalViewController. Looking at the documentation I can't find a way in which this is possible! In OS4, there is something like this: UIWindow *window = [UIApplication s...

Objective C: [MyObject alloc] now crashes under iOS SDK 4.1

I'm working on an existing, large-ish codebase, and after upgrading the iOS SDK to 4.1 I am now seeing very strange behaviour. The crux of the matter appears to be a particular class that will no longer alloc - it is throwing a bad access in obj_msgSend, and seems to be the Class object on the stack that objc_msgSend doesn't like - altho...

are objective-c blocks similar to anonymus functions in javascript?

Hi, i am trying to understand the concept of blocks. What i've read so far seems to be conceptually similar to anonymous functions in javascript. Is this correct? ...

Implementing horizontal scrolling in a UITable (row by row) for iPhone

As per the question, I'm looking to implement a video selector with different categories. This would be very similar to the BBC app in approach. I don't seem to be able to find anything that fits the bill though, has anyone got any good ideas for how I might be able to do this/an API freely available that does it. See example: http:/...

Safely dealloc'ing a Timer

I create a timer in my ViewDidLoad method of my view-controller. NSMethodSignature *sgn = [self methodSignatureForSelector:@selector(gameLoop:)]; NSInvocation *inv = [NSInvocation invocationWithMethodSignature: sgn]; [inv setTarget: self]; [inv setSelector:@selector(gameLoop:)]; NSTimer *t = [NSTimer timerWithTimeInterval: 1./30. ...

Is it safe to ignore the warning: Value stored in delayTimer is never read?

This is how my code looks currently NSTimer *delayTimer; delayTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(longRunner) userInfo:nil ...

Disallow UIScrollView from catching subviews touches

I've got a UIScrollView covered with a custom UIView which desperatly needs to listen to all the touch events that happen inside of him. At first, all I was getting was touchesBegan: and touchesCancelled: events. No touchesMoved:, no touchesEnded:. In fact, all the dragging gestures where being canceled by the above UIScrollView. This w...

Objective c - Rotate wheel using radians

Hi, I am trying to make a circle image which rotates when the user drags the wheel This is my code: CABasicAnimation *rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; rotationAnimation.toValue = [NSNumber numberWithFloat:angleRadians]; rotationAnimation.duration = 10; rotationAnima...

Protected methods in objective-c

What is the equivalent to protected methods in objective-c? I want to define methods which only the derived classes may call/implement. ...