objective-c

Why does shouldAutorotateToInterfaceOrientation always get called twice on launch?

Hi I have a simple viewcontroller based application. Can someone tell me why shouldAutorotateToInterfaceOrientation seems to get called twice (value equals 1 both times) on launch? ...

Difference between transforming a view's layer and transforming a view directly?

Hi Trying to both translate(x,y) and scale some images when my application rotates. It seems there are more than 1 way to do this. I can use 'setValue forKeyPath' method to transform a view's layer [containerView.layer setValue:[NSNumber numberWithFloat: .7] forKeyPath: @"transform.scale.x"]; [containerView.layer setValue:[NSNumber...

How to search an NSSet or NSArray for an object which has an specific value for an specific property?

How to search an NSSet or NSArray for an object which has an specific value for an specific property? Example: I have an NSSet with 20 objects, and every object has an type property. I want to get the first object which has [theObject.type isEqualToString:@"standard"]. I remember that it was possible to use predicates somehow for this ...

releasing object after return

Hi, I use an object to get some values with it and return this values. The values which will be returned are still in this object. Heres the code: XMLErrorParser *xmlErrorParser = [XMLErrorParser alloc]; [xmlErrorParser parseData: data]; return xmlErrorParser.errors; So how can i release the xmlErrorParser Object and retu...

iPhone SDK: Please explain why "nil ==" is different than "== nil"

I have been programming iPhone SDK for around 6 months but am a bit confused about a couple of things...one of which I am asking here: Why are the following considered different? if (varOrObject == nil) { } vs if (nil == varOrObject) { } Coming from a perl background this is confusing to me... Can someone please explain why on...

Save NSmutableArray to file and load

hello all , i am written app for my iphone and i want to save some NSmutablearray to file and load it later. i read about NSArchiver but didnt understand how to work with my calss is : @interface Shop : NSObject { NSString *m_Name; NSString *m_Description; NSString *m_Category; NSString *m...

Core Data crashed - a rarely happened error on the device

I got this crash log while querying an array of managed object, however, while running in the simulator it does not happen. Even in the device, sometimes it happens, sometimes not. Someone can explain to me why and what is the error? Incident Identifier: 0ED2BB7C-5E8F-483B-AE08-8DE2C14D0C23 CrashReporter Key: e24b9614a897f92ee13ce00b7...

How to dynamically build up the arguments for NSLog?

Example: I have a complex method that does a lot of stuff, and at the end I want to print a report with NSLog. NSLog wants a string, and then an arbitrary number of arguments. So lets say there are these possible values which can be logged: A B C D E F It can happen that -for example- C and D are not logged, but the whole rest. Ho...

What's the difference between using Quartz & C vs ObjectiveC to load images?

In the Resource Programming Guide it gives 2 methods to load image resources, using Quartz & C vs ObjectiveC . Can anyone tell me what the difference is? Are both identical in terms of performance with a large number of images? ...

How to check if UILabel is truncated?

I have a UILabel that can be varying lengths depending on whether or not my app is running in portrait or landscape mode on an iPhone or iPad. When the text is too long to show on one line and it truncates I want the user to be able to press it and get a popup of the full text. How can I check to see if the UILabel is truncating the te...

Texture2D implementation on iPhone problem

Im trying draw text using Texture2D but all I get is a big white square. What wrong? glPushMatrix(); glRotatef(rodar+30, 0, 1, 0); glEnable(GL_BLEND); tex = [[Texture2D alloc] initWithString:@"imm" dimensions:CGSizeMake(2,1) alignment:UITextAlignmentCenter fontName:@"arial" fontSize:5]; [tex dra...

create jigsaw puzzle piece from an existing image on iPhone

How would one go about creating jigsaw puzzle pieces from an image on the fly. I want the application to get the images from the library and then create puzzle pieces around that. Any ideas? open source libs? ...

obj-c : iphone programming, call method with 2 parameters

i have a method that call another method with 1 parameter to another class. It is working perfectly but now i need 1 more parameters this is my code : i am getting a 'addobject may not respond' test.m calling method : DrunkeNewIdeaAppDelegate *appDelegate = (DrunkeNewIdeaAppDelegate *)[[UIApplication sharedApplication] delegate]; ...

Objective-c linking error with duplicate-symbol error

I am new to Objective C and have the following error when trying to import a class defined by me Building target “MusicCube” of project “MusicCube” with configuration “Debug” — (1 error) cd /Users/varsha_vijay/Downloads/MusicCube setenv MACOSX_DEPLOYMENT_TARGET 10.5 setenv PATH "/Xcode3.1.4/Platforms/iPhoneSimulator.platfo...

How to sync CoreData and a REST web service asynchronously and the same time properly propagate any REST errors into the UI

Hey, I'm working on the model layer for our app here. Some of the requirements are like this: 1. It should work on iPhone OS 3.0+. 2. The source of our data is a RESTful Rails application. 3. We should cache the data locally using Core Data. 4. The client code (our UI controllers) should have as little knowledge about any network stuff ...

NSAppleScript Wont Work.

Can someone please tell me why this won't work? NSAppleScript* playPause = [[NSAppleScript alloc] initWithSource: @"\ tell application \"System Events\"\n\ tell application \"Final Cut Pro\" to activate\n\ keystroke \" \"\ end tell"]; I get the error "Expected ':' ',' ';' '}' or 'attribute' before '=' token". WT...

How to message an object?

I am working in objective-C trying to write an iphone app. Background: There is a navigation controller managing my view controllers. My FirstLevelViewController on viewDidLoad creates a few SecondLevelViewController Objects, stores them in an array, and then loads them when various table cells are pushed. In addition, on viewDidLoad,...

CCLabel on iPad really slow?

Hello, i'm using cocos2d to make an ipad app and i'm just starting out. So i added a label to my HelloWorld scene and when i tested it out it was really slow. Like i was getting 30 - 40 fps out of 60. i figured out that label's size that was causing the drop in fps. it is a fontsize 128when this happens and i'm just wondering if cclabel...

UINavigationController: Simplest Example

I'm trying to do very simple example of a UINavigationController. Here is my code: - (void)viewDidLoad { [super viewDidLoad]; This next line works, or at least doesn't blow up. navController = [[UINavigationController alloc] initWithRootViewController:self]; self.title = @"blah"; PageOneController *one = [[[PageOneControlle...

How does loadNibNamed?

In most of the samples the return value from loadNibNamed value is not used, so I guess it's using the owner argument. But how does it work and make the connection to the owner object? What kind of requirements should my owner class meet in order to load a nib in such way? The only requirements I can guess is that the owner class mus...