objective-c

Common base class/code for UIView and UIImageView - alternative to multiple inheritance in objective-c

I have some functionality that I need in all my classes which derive from either UIView or UIImageView. More specifically, I have gesture related code that both these classes need. Currently my implementation is: UIGestureView : UIView UIGestureImageView : UIImageView and make all classes derive from these. These classes will again c...

"warning: '<CLASS>'may not respond to '<[-|+]FUNCTION>'" Objective C/Xcode Compiler Warnings

I figured this one out, yet thought it worthy of its own question answer pair. I'm new to Xcode and Objective C, and getting to know its varied eccentricities. For instance, the compiler warning "warning: ''may not respond to '<[-|+]FUNCTION>'" appears when I try to compile the following code, which all appears in my implementation file...

iSimulate Automatic Hooks

I was wondering if anyone knew how iSimulate automatically registers/hooks itself into a debugged iDevice application? It's as simple as including the static library (and a couple of frameworks) and it just works. There are no methods or functions to call. How is this possible? ...

Realtime formatting with NSNumberFormatter in a UITextfield

I have UITextfield where a user can put in a dollar amount, I would like the textfield always to be formatted with two decimals ($ .##). The formatting has to be maintained all the time. But i'm stuck on how to append the entered numbers to existing ones in the textfield ? //This delegate is called everytime a character is inserted in ...

UIViewController parentViewController access properties

I know this question has been asked several times and I did read existing posts on this topic but I still need help. I have 2 UIViewControllers - Parent and Child. I display the child view using the presentModalViewController as below: ChildController *child = [[ChildController alloc[ initWithNibName:@"ChildView" bundle:nil]; [self pr...

How to Make a Basic Finite State Machine in Objective-C

I am attempting to build an FSM to control a timer in (iphone sdk) objective c. I felt it was a necessary step, because I was otherwise ending up with nasty spaghetti code containing pages of if-then statements. The complexity, non-readability, and difficulty of adding/changing features lead me to attempt a more formal solution like this...

Iphone call method from another class

I have a multiple XIB file project. I have a switchViewController class that handles the switching of content views. I want to call the methods in this class from other classes. I have the following code: //SwitchViewController.h Code: #import <UIKit/UIKit.h> @class MainMenuViewController; @class GlassRepairsViewController; @inter...

Programmatically hook up events to methods?

Is there a way to hookup a button click to a method programmatically? It would be like imitating the CTRL+CLICK in Interface Builder. ...

Cocoa Touch & Sql Server

Is it possible to connect to Sql Server for the purpose of executing simple Sql commands within a native iPhone app? If so, how does one go about it? I'm stumped. More generally, I would at least like to see how this is done with GCC. Thanks in advance, Rich ...

Drawing a Shadow after the CGContextClip with Core Graphics

UPDATE: I tried implementing the method specified by Peter and am getting incorrect shadowing. What is wrong? CGContextSetShadowWithColor(c, CGSizeMake(4, 4), kAudioThumbShadowBlur, [[UAColor blackColor] CGColor]); CGContextFillPath(c); CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, minx, mid...

How do I make the modal view only come up half way?

So I have an app where you play a game, and at the end it asks you your name for recording of the high score. I would like to use a modal view to accomplish this, but I am experiencing some hiccups along the way. So far, all I have is the modal view sliding up all the way to the top of the screen, but there isn't anything there yet, it's...

objective-c Derived class may not respond to base class method

Hi, I have derived from a 3rd party class, and when I attempt to call a method in the base class, I get the x may not respond to y compiler warning. How can I remove the warning? Repro: @interface ThirdPartyBaseClass : NSObject {} +(id)build; -(void)doStuff; @end @implementation ThirdPartyBaseClass +(id) build{ return [[[self al...

Arrange UIView subviews in relation to outside UIViews

How do I arrange (in terms of depth) a view's subview to be in front of another view? The hierarchy looks like this: A-- -C -D B-- -E -F (A and B are views with C & D, and E & F, as subviews, respectively.) B is layered above A, so every subview in B (E and F) is above every subview in A (C and D). How can I make C displ...

Detecting when a space changes in Spaces in Mac OS X

Let's say I want to write a simple Cocoa app to make the Spaces feature of Leopard more useful. I would like to configure each space to have, say, different *screen resolutions *keyboard layouts *volume (for audio) So there are two parts to my question: 1) I suppose there are ways to modify these three things independently of Spaces, r...

Parsing nested JSON objects with JSON Framework for Objective-C

I have the following JSON object: { "response": { "status": 200 }, "messages": [ { "message": { "user": "value" "pass": "value", "url": "value" } ] } } I am using JSON-Framework (also tried JSON Touch) to parse through this and create a dictionary. I want to access the...

Default value of an Objective-C struct and how to test

I'm trying to test if a property has been set yet. I know that with objects that I've got: CGRect ppGoalFrame; LocalPlaySetup *localPlaySetup; and I can test if (localPlaySetup == nil) but if I attempt to test the CGRect with == nil or == NULL if (ppGoalFrame == nil) I get invalid operands to binary == (have 'CGRect' and 'void...

"Content URL must not be nil" error when playing video

I am playing video from a local file in my application and it works properly, but then suddenly playing the video crashes the application with this error: 2010-03-10 11:34:20.235 SanjeevKapoor[1560:20b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Content URL must not be nil.' This is...

How to create a program using NSURLConnection?

Hi, I need a simple example program using NSURLConnection which inturn uses NSURLRequest,NSURL Response classes.Thanks in advance. ...

libssh2 wrong library for connection with User agent + iPhoneSDK

Hello Guys, back here with libssh2 again..! I'm encountering few problems with the user agent... I need to setup a connection with libssh2 in such manners, if password, username is not specified, they should be asked from virtual command-prompt on iPhone. We've developed a command-line emulator, its's working good.Right now the proble...

Problem in recordsetting of AvAudioRecord in Iphone sdk

Hi Guys, Here I am getting the Exception when I am setting the recordsetting in AvAudioRecord. The code I written is as: I created a button named Record and in the action I used the code as... I imported the audio file sound.caf [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryRecord error: nil]; NS...