objective-c

Different code / config in Release & Debug build (Obj-C)

Hi, I'm writing a Cocoa app in Objective C that's communicating with a webservice and I want it to connect to a sandbox in debug mode and to the real webservice in release mode. All I need is to change on line of code where an object that holds the configuration gets instantiated (with a different init-message and different parameters). ...

Can Cocoa Touch UI objects be serialized, transmitted over a network, and reconstituted on a client?

I've been working on and off with a team that's developing an iPhone app. Like a lot of other developers new to Cocoa Touch, we decided to create a hybrid Cocoa-Web app which was essentially a few buttons controlling some UIWebViews -- partly to (a) leverage existing web development expertise, partly because of (b) the advantage in pushi...

How to "fake" ivars in an Obj-C category (iPhone)

Update: iPhone OS 3.1 has associated objects. However, the iPhone simulator does not. If you want to test associated objects code in the simulator, you should file a bug. See my SO question here. rdar://7477326 Snow Leopard now has associated objects. Is there a way to accomplish something similar without associated objects? (Spe...

Building a backwards compatible OS X app, when a new API is present?

I'm trying to upgrade an app (Clarke) to provide 10.6 compatibility. My plan is to use two different code paths depending on the version of OSX in use. On 10.5 it will use one controller, which consists of completely custom code that isn't dependent on any specific Cocoa API. On 10.6 it will use another controller, which wraps the new...

1 little error in my transition coding

Full Size Image Here you can see the code for the transition but it says there is an error before the "for" What is it that i'm missing? I basically want to do a fade in between images. EDIT Here is the updated code with the adjustments. I am still getting that error. Updated Code The *NSArray** theImages line ends with the f...

How do you change the state of the window close button in Cocoa?

In Cocoa Applications, you often see a little red dot in the window's close button when you have unsaved data; TextEdit is a good example of this. I've pored through the Cocoa documentation but I can't find a way to programmatically set this state. I'm sure there's some really easy way to do it, but obviously I'm missing something. ...

Why is sizeWithFont:constrainedToSize:lineBreakMode: returning an incorrect size?

I have two possible widths for a string i want to display in a label in a table cell, and i need to compute the height so that the table cell's height is recorded correctly. however, no matter what I do for the constraining size i get the same height, which is incorrect in the case i want. The code i'm using: CGFloat width = 300.0f; N...

Getter Sequence Of Events?

I am trying to understand what is happening in the getter below, this is what I understand so far: (1) the getter returns a pointer to an NSString object. (2) the NSString object is retained, possibly because we have just given away a pointer to it. (3) autorelease? when does that activate, when the PlanetClass instance is deallocated (...

Providing data as needed for QTMovie

I understand that if I wanted to provide a QTMovie with data from an arbitrary source as it is needed I probably have to deal with the QTDataReference class, but unfortunately my experience with anything similar is limited to an audio data callback with Audio Buffers on the iPhone. If I initialized the QTDataReference with some NSMutabl...

Disapperiang IPhone Numeric Keyboard

How I can disappear numeric keyboard in iPhone because there is no return key in it, which implies it is not going to respond to - (BOOL)textFieldShouldReturn:(UITextField *)textField ...

Is it "bad" to use @properties for private variables just for the memory management benefits?

Is it bad to create @properties for private variables just for the memory management benefits? It seems messy and wrong to have public facing @properties for many private variables. (Mainly, I am releasing private ivars during low memory conditions using the respective "event" methods.) Example: I usually do this to release a private ...

Can someone explain what a delegate is with an example?

i read a lot about objective c delegate but didn't get clear idea.Can anyone explain it with a good and precise example so that i can understand it. Advanced thanks for your reply. ...

Objective-C Delegate question

From reference: http://stackoverflow.com/questions/1408774/objective-c-delegate-explanation-with-example NICK wrote: For example, class A asks you for a delegate. You tell it [this] instance of class B will do. [a setDelegate:b]; What is a? Is it a instance of Class of A? ...

What am I doing wrong in my code?

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *myPlistPath = [documentsDirectory stringByAppendingPathComponent:@"Accounts.plist"]; NSArray *arr = [NSArray arrayWithContentsOfFile:myPlistPath]; int count = 0; for (N...

NSData to NSString converstion problem!

Hi guys, I'm getting an html file as NSData and need to parse it to extract some info. My approach was to convert it to NSString with UTF8 encoding (the html has non english characters, russian for example) - it failed. I used something like that: NSString *respData = [NSString stringWithUTF8String:[theData bytes]]; but it returned n...

Carbon VS Objective-C & intel-based mac

Is it possible to develop carbon application in objective-C, moreover what if i don't have a power PC based mac and i have an intel-based mac, can i still develop applications for Carbon? Regards. ...

How to attach more than one controller to views its subviews

Hi,Friends plz help me out I am a newbie in iphone development its my second sample code. I am trying to add sub-views to a View and generate events according to the view/subview which is touched.i have added subviews in main view and all are showing all at one time. The projects I am experimenting with is a newly created, clean Window-B...

Flip Animation not working

I have a Custom view. This custom view has two UIImageViews - imageview1 and imageview2. [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2.00]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(transitionDidStop:finished:context:)]; [UIView setAnimationTransition:UIV...

question concerning NSLog output %i, %d

I have question concerning a function I created. I would like to show the timeinterval in my console output. -(void)MyTimeInterval:(id)sender { NSDate *then = [NSDate date]; NSDate *now = [NSDate date]; NSTimeInterval interval = [now timeIntervalSinceDate:then]; NSLog(@"let me see the timeinterval between now and th...

Building better positional audio [AudioQueue manipulation]

Hey folks, I'm building an app that has a requirement for really accurate positional audio, down to the level of modelling inter-aural time difference (ITD), the slight delay difference between stereo channels that varies with a sound's position relative to a listener. Unfortunately, the iPhone's implementation of OpenAL doesn't have th...