objective-c

Simple Animation with NSTimer and opacity for the iPhone

Hello, I just want to realize a simple animation, where a picture is faded in a few seconds after the beginning of the application and then it should be faded out and totally disappear. I've never done any animations on the iPhone so I'm stuck. When using something like image.opacity = 1.0; like in the Developer Documentation I get: erro...

Passing a C++ method to an Objective-C method

I have a C++ class 'Expression' with a method I'd like to use in my Objective-C class 'GraphVC'. class Expression { double evaluate(double); } And my Objective-C class: @implementation GraphVC : UIViewController { - (void)plot:(double(*)(double))f; @end I thought that it would be easiest to pass around function pointers that ta...

Adding Padding To The 'left' of a Text Field.

I have a text field with a background but to make it look right the text field needs to have some padding on the left side of it a bit like the NSSearchField does. How would I give the text field some padding on the left? ...

Bad response code when uploading image with Twitpic API

Can anybody familiar with the source code for uploading image to Twitter using "Twitpic api" please tell why I get a 0 response code when I am trying to upload an image? Here is my code: - (BOOL)uploadImageToTwitpic:(UIImage*)image withMessage:(NSString*)theMessage username:(NSString*)username ...

hitting a next button for a UITableViewcell

Hello all , I was wondering how I can realize the following: Creating a next button and when it's tapped the next UITableview row will be selected. Since a picture is worth a thousand words I've added a screenshot. http://img529.imageshack.us/img529/4341/picture5uuj.png As you can see below I added a toolbar and if I press the rig...

Storing optional NSNumber in Core Data

In my core data model, I have an entity with an optional NSNumber attribute. How do I test to see if the value in that attribute is valid or not? When I test for nil... doesn't work. [self numberAttribute] == nil // always returns NO When I test for a zero value int, that doesn't work. [[self numberAttribute] intValue] == 0 /...

Running a socket stream in a thread

I have an application that opens a connection with 2 sockets (in and out) and I want to have them working in a thread. The reason that I want them to be in a separate thread is that I don't want my application to freeze when I receive data, and this can happen anytime as long as the application is running. Currently I have a class that...

How to show UIWebView's scroll indicators

Hi, all I have UIWebView with some content And i need to make its scroll indicator visible for a short time (like [UIScrollView flashScrollIndicators]) Any ideas, how to do this? Thanks. ...

Data server to iPhone and back

Web services -> core data -> controller -> view and then reverse... Sound right? Or is there a better way, one that avoids the complexity of SOAP? Additionally can core Data recognize XML coming from SOAP? Thanks // :) ...

Multiple views in a UIWindow

I have a "navigation based application" which also needs to have a view always displayed at the bottom of the screen at all times. I added this new view to a UIWindow after adding the UINavigationController's view: // In my delegate's applicationDidFinishLaunching method [window addSubview:navigationController.view]; [window insertSubvi...

How to convert an NSTimeInterval (seconds) into minutes

Hi, I've got an amount of seconds that passed from a certain event. It's stored in a NSTimeInterval data type. I want to convert it into minutes and seconds. For example I have: "326.4" seconds and I want to convert it into the following string: "5:26". What is the best way to achieve this goal? Thanks. ...

How to know if user prefers miles or kilometers?

Hi, In my app I've got a certain distance in meters. And I want to display it in kilometers if user prefers kilometers and display it in miles if user prefers miles. And in the first case I want to add to a string "kilometers" at the end and in the second one to add "miles". What is the best way to achieve this goal? Thanks. ...

MKMapView refresh after pin moves

A custom AnnotationView is updated with new coordinates. But the problem is that it visually updates only after some manipulations with MKMapView, e.g. zooming or moving. What should I do to manually update visual position on a map? PS. I've tried to change region to current map's region. But it does change zoom. It's strange. [mapView...

Count the number of times a method is called in Cocoa-Touch?

I have a small app that uses cocos2d to run through four "levels" of a game in which each level is exactly the same thing. After the fourth level is run, I want to display an end game scene. The only way I have been able to handle this is by making four methods, one for each level. Gross. I have run into this situation several times ...

Scrolling to range in UITextView

I have a UITextView with text in it, and I want to be able to scroll it such that a given NSRange of the text is at the top of the view. Using scrollRangeToVisible: does not work: it will scroll the range such that it is somewhere in the view, not necessarily where I want it to be. How can I scroll such that this specific NSRange of text...

Multithreaded iPhone app crashes with [NSAutoreleasePool release]

Hi, I have a memory management-related question in a multithreaded iPhone application. Let's say we have this method, that is called in a separate thread than the main-UI-thread: - (BOOL)fetchAtIndex:(NSUInteger)index { NSURL *theURL = [NSURL URLWithString:[queryURLs objectAtIndex:index]]; // Pay attention to this line: NSD...

iPhone Sound: Adjust speed of playback of audio file while playing

Hi, is there a way to adjust the speed of the playback of an audio while playing in Objective C for the iPhone/iPod touch? Also would be interesting if playing a file backwards would be possible. Thanks Tom ...

How to inherit from NSDictionary?

I have an object called Settings that inherits from NSMutableDictionary. When I try to initialize this object using Settings *settings = [[Settings alloc] initWithContentsOfFile: @"someFile"] it returns an object of type NSCFDictionary. As a result, it doesn't recognize my additional methods. For example, when I call the selector ...

UIDatePicker in UIActionSheet layering problem

Someone posted this code in another question to put a UIDatePicker in a UIAlertSheet: UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Date Picker" delegate:self cancelButtonTitle:@"Cancel" destruct...

Is there a method in Objective-C to recursively create directories from a string?

I am trying to write to the iPhone app's cache folder with images downloaded from a server. My plan is to save the images in "site.com/path/to/image.jpg", since mirroring the server folder structure like that makes duplicate names impossible, and it just seems the right way to do it. Unfortunately, it seems I have to create the folders m...