objective-c

How to Instantiate and Call UIView Subclasses Without Using a Nib

Without using Interface builder or xib files, what is the correct way to instantiate two classes which inherit from UIView such that they can switch between themselves using UIButtons located on the views themselves? I think this involves setting up a UIViewController from the app delegate and adding two instances of my classes which im...

IBOutlet declarations?

I have seen the code below written 3 different ways (with regards to IBOutlet) Does it matter, I would say adding IBOutlet to both the declaration and the @property was more concise. JUST PROPERTY: @class SwitchViewController; @interface iPhone_switcherAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; SwitchVi...

Button should trigger more than on task (NSButton, NSTabView)

After a click of a Button I want to change to the next TabView and trigger the outcome of another class instance? Any Examples somebody could give me? ...

Dot notation using setter?

Given the property declaration below, does method (A) work in exactly the same way as method (B). I just want to check that self.yellowViewController = yellcon_New is going via my setter so that the old objects gets release and the new one retained? // INTERFACE @property(nonatomic, retain) YellowViewController *yellowViewController; /...

Objective-C object gets deallocated unexpectedly

I'm very new to Objective-C and I'm trying to develop an iPhone app. My problem is I get "message sent to deallocated instance 0x3d54830" error when I use an object inside an NSTimer. When I don't use an NSTimer, I can use the object just fine. For example: //These can be any objects. Le't say I have a Song class and a SongReader clas...

Return value For NSDictionary On Simulator, iPhone

Hello there, I have some code which requires an iPhone to run. I do however want to test my app on the simulator. On the iPhone I use this to return a value: return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:-1], @"number"]; I'm looking for something like this I THINK: - (NSDictionary *) data { #if TARGET...

IPhone: Adding Category to CoreLocation threw link error. Why?

Hi I added a category to CLLocation in CoreLocation but kept getting a link error. I search around and through process of TRY IT AND BE DAMNED I fixed the problem by adding -framework CoreLocation to Other Linker Flags But dont know why? I'm guessing its something to do with CoreLocation being and external framework. The Code: CLLoca...

Re-assignment of variable doesn't work

I have a puzzling problem -- it seems like it should be so easy to do but somehow it is not working. I have an object called Player. The Manager class has four instances of Player: @interface Manager { Player *p1, *p2, *mCurrentPlayer, *mCurrentOpponent; } // @property... The Manager object has initPlayers and swapPlayers meth...

Singletons in Objective-C for storing and accessing program-wide variables. A few questions

Hi all! I am using Apple's MyGizmoClass Singleton class for program-wide "session variables" and loving it! However, when I run "Build and Analyze" it gives weird results. Maybe my usage is wrong (it works, but it may be working due to a flakey side effect). Here is an example. - (NSInteger)tableView:(UITableView *)tableView numberO...

Incompatible type for argument 1 of 'bezierPathWithOvalInRect' error

Hi, I have the following code: - (void)drawRect:(NSRect)dirtyRect { [[NSBezierPath bezierPathWithOvalInRect:[self theRect]] stroke]; } - (NSRect)theRect { return NSMakeRect(1, 1, 1, 1); // made up some values } When I compile it says "Incompatible type for argument 1 of 'bezierPathWithOvalInRect' error". When I do this, howev...

iPad / iPhone Sync (WLAN or Inet)

I have actually one app with a SQLite DB and i port this at the moment to the ipad. My idea is a sync between iPad and iPhone for one table... But the Problem is "Person A" edit/change, create or delete a data record on iphone and "Person B" make the same or delete the edited record from Person A on the same time. Has anybody a idea for...

Making view transitions fast - do you use this hack?

I have an iPhone app that displays a modal view controller. The modal view controller shows two instances of a custom subclass of UITextView called RoundedTextView, an MKMapView, and a UIToolbar. I construct the viewController only once, and reset its data and present it each time the user summons it. When showing this view controller w...

Bindings AND target/action?

Hi, I currently have a color well which keeps track of a color that gets saved in the NSUserDefaults. It is bound to an NSUserDefaultsController. However, I also want to listen for changes to the color so I can update my views accordingly. Therefore, in addition to the binding, I added a target/action to the color well to my preferences...

Objective-C iPhone - Playing youtube within an app

Hi, Is it possible to play youtube using the method described in this url http://iphoneincubator.com/blog/audio-video/how-to-play-youtube-videos-within-an-application but with a custom button? (i.e in the picture in the link, it's of a baseball game with the play button overlay on top, I want that to be a custom button that I create) ...

Xcode "infinite loop" inconsistency

When running this code under debug in the iPhone simulator, it correctly exits with r==4 after 5 iterations of the loop:- int r; for (r = 0;;r++) { if (r == 4) break; } Without the braces, it exits with r==1 after 1 iteration:- int r; for (r = 0;;r++) if (r == 4) break; Without the braces, but with a test ex...

Initializer 'initWithRequest' reserved in the API?

Are the names of some initializer methods like 'initWithRequest' reserved in the API? I have the following classes @interface MTURLRequest : NSObject { ... } ... @end and @class MTURLRequest; @protocol MTURLRequestHandlerDelegate; @interface MTURLRequestHandler : NSObject { ... } -(id)initWithRequest:(MTURLRequest*)request_ d...

iPhone Quartz 2d development using C++?

Could I write c++ code that interacts with the iPhone Quartz 2D framework, or can I only using objective-c? Thanks ...

How do I define and use an ENUM in Objective-C?

I declared an enum in my implementation file as shown below, and declared a variable of that type in my interface as PlayerState thePlayerState; and used the variable in my methods. But I am getting errors stating that it is undeclared. How do I correctly declare and use a variable of type PlayerState in my methods?: In the .m file @im...

Crash in FixMath and MachineExceptions.h after adding AudioToolbox.framework

Made a new window application. Right-clicked Frameworks > Add Existing Frameworks. Selected Frameworks folder, then AudioToolbox.framework. Build, and 11 crashes. #elif defined __ppc__ || __ppc64__ #define _IntSaturate(x) ((int) (x)) #else #error "Unknown architecture." // To use unoptimized standard C code, remove above line. #defi...

Compensating For Value Change While Changing Value?

i'm attempting to add my own continuous pitch modulation (vibrato) to my OpenAL object by assigning the sound's pitch to the path of a sine wave. this is my callback method, which is repeating every 1/30 of a second, as well as the getter and setter for the pitch. #define kMaximumAplitude 0.025 #define kVibratoDegreeIncrements is 45 #d...