objective-c

iphone: Calculating battery life

Wondering if there are references beyond the Apple tech stats for calculating battery life. I've tried comparing some existing battery apps (battery % left * Apple's figures) and I dont come up with the same answers sometimes. Also there are stats for using 2G cell (as opposed to 3G) and I dont see anything on Apple for 2G battery life. ...

iPhone, special characters in JSON Response

Writing an iphone app, and I'm getting my data from a REST API that returns JSON. My problem is, some of the data has special characters embedded and Im getting errors. Example: MartÌn Petite-RiviËre-Saint-FranÁois Here is my current code: NSString *jsonString = [[NSString alloc] initWithData:receivedData...

UIViewController - can't become first responder

Hi, anyone knows why UIViewController wouldn't become first responder when I run this code: [self becomeFirstResponder]; NSLog(@"is first resp: %i",[self isFirstResponder]); In the console, I always see the line: "is first resp: 0" I HAVE canBecomeFirstResponder method: - (BOOL)canBecomeFirstResponder { return YES; } I don't even ...

Application crashing on getting updated information from database using timer and storing it on local data structures

In our multi - user application we are continuously interacting with database. We have a common class through which we are sending POST queries to database and obtaining xml files in return. We are using delegates of NSXMLParser to parse the obtained file. The problem with us is we are facing many crashes in it generally when application...

UIImageView Class problem

Hello , I have taken an Imageview class and iam adding image into that with code: TileImageView *tileImageView = [[Tile alloc] initWithImage:tileImage]; and adding into view like this:[self.view insertSubview:tileImageView atIndex:0]; So how to remove the Imageview class and alloc new image to that view ...

No stringWithContentsofURL method found

I'm following this tutorial, attempting to learn a bit about iPhone development, and there come a point where the author uses the stringWithContentsofURL method but xcode is telling me that there is no stringWithContentsofURL method found. I've done some searching and I've not been able to come up with a solution. This is a screen shot...

Is there any tutorial out there on key value coding and Key Value Observing?

Hi, I was wondering if there is any tutorial out there on Key Value Coding and Key Value observing, which use simple classes to explain these concepts instead of using cocoa. Apple programming guides sucks on this matter :@ Correction: When i am referring to Cocoa here, i mean use of Interface Stuff, sorry for using the wrong word, it'...

Avoid iPhone constant polling a web-service?

I have an iPhone application that needs to be updated as soon as a change is made to the server. How can I have the server "push" data to the iphone rather than the iphone constantly polling the web service? EDIT: I want th iPhone to receive JSON updates as soon as the server processes them, without having to request. I suppose since t...

how to swap images using Cocoa Touch

I am trying to build 15-puzzle game. Here I need to swap a blank image with a clicked on image. I would like to know how to swap these images. I have stored the co-ordinates of the two images,but don't know the format to identify the blank image and then set its origin to clicked image. ...

What folder should my application write its launchd file?

I am trying to write a small Cocoa application that helps me manage my time, I want it check on startup if already has a launchd entry and if not, add itself an entry. What is the correct folder to write the launchd file, and/or is there a special cocoa method to retrieve what the correct folder is (ie in the same way you retrieve the u...

Problem compiling a simple test project for the iPhone.

I am new to iphone development. I have this code in the delegate.h section: #import <UIKit/UIKit.h> #import <objc/Object.h> @class Learning1ViewController; @interface Greeter: NSObject<UIApplicationDelegate> { } -(void)greet; @end #include <stdio.h> @implementation Greeter -(void) greet { printf ("Hello, World!\n"); } #includ...

How to move non static variables from interface to implementation in objectiveC?

Hey, I am trying to write a cocoa touch static library. To keep it simple I would prefer not to use private variables within my interface file. The code right now looks like this: interface file (myView.h): @interface myView: UIView { NSTimer * myTimer; } @end implementation file (myView.h) @implementation myView @end This NS...

How to calculate the time difference between two locations.

I am having a problem with calculating time difference between two timeZones. If I am at location A I know the latitude and longitude and the current time. I go to location B I know the latitude and longitude and the current time. How to calculate the time difference between the two current points .. (in UTC) ...

iphone application

Hello I want to make use of kooaba in my iphone application, can anybody plz tell me how can i send a query to kooaba API and how can I use that kooaba API to recognize the image from my application.Where I have to send my photo using kooaba?? ...

How to validate an url on the iPhone

In an iPhone app I am developing, there is a setting in which you can enter a URL, because of form & function this URL needs to be validated online as well as offline. So far I haven't been able to find any method to validate the url, so the question is; How do I validate an URL input on the iPhone (Objective-C) online as well as offli...

is it possible to use AVAudioRecorder alongwith MPMusicPlayerController?

Hello all, When a song from iPod chosen using MPMediaQuery is playing with MPMusicPlayerController, is it possible to record a clip of the song using AVAudioRecorder? ...

Tinting iPhone application screen red

I'm trying to place a red tint on all the screens of my iPhone application. I've experimented on a bitmap and found I get the effect I want by compositing a dark red color onto the screen image using Multiply (kCGBlendModeMultiply). So the question is how to efficiently do this in real time on the iPhone? One dumb way might be to grab...

Object Makeup, how its constructed?

These are fairly simplistic questions, but something that I wanted to get right in my head before continuing... @interface BasicTire : NSObject { } @end @interface SnowTire : BasicTire { } @end When you call [SnowTire init] the included [super init] calls [BasicTire init] which in turn calls [NSObject init]? (i.e. a cascade running...

Track system activity

Is there a neat/easy way in objective-c/cocoa to track if a user is at their computer, ie I assume by detecting key presses and mouse movement? (ie I want to fill out my timesheet automatically by detecting when I am at work and not at work) ...

Using AtlasSprite as a parent class - Giving problems on propreties on the class

I am trying to have AtlasSprite as a parent class but it's giving me errors on propreties. Like it can't seem to find them: Here's the code extract. interface: @interface Glyph : AtlasSprite{ float eyelevel; } @property (readwrite,assign) float eyelevel; -(id) initWithMgr:(id) mgr; implementation: @implementation Glyph @synthesi...