objective-c

Genertate random color hex in Objective-C ?

How do I generate a random color hexadecimal in Objective-C ? I need a color hexdecimal , I don't need a random color. It is complicated ... ...

how do i get a layer's frame to automatically resize based on its superlayer's frame or its view's frame?

I'm experimenting with using cagradientlayer to draw gradients in our app instead of having a subclass of uiview manage gradients. One snafu that i've come across is that when the view that has the gradient as a sublayer of its main layer gets resized to fit the data i am trying to show, the layer doesn't resize along with it. I end up...

Should i release return object from CGImageSourceCopyPropertiesAtIndex call?

It's not stated in documentation for CGImageSourceCopyPropertiesAtIndex function. But am i right that i should call CFRelease on retured CFDictionaryRef ? Quick sample: NSDictionary* metadata = (NSDictionary *)CGImageSourceCopyPropertiesAtIndex(source,0,NULL); ...................... //Should i call CFRelease(metadata); ?? Thanks. ...

Does NSClassFromString affect performance?

I want to create a controller that depends on the class of a given instance of a model -(BaseController *)getControllerForModel:(Model *)model { BaseController *controller = nil; Class controllerClass = [BaseController class]; //the default value //find the right controller if ([model isMemberOfClass:[Mod...

NSURLConnection connectionWithRequest blocks interface

Hi all. I thought the reason behind having asynchronous requests is to have it run in the background? Well, I'm uploading something using NSURLConnection connectionWithRequest, it all works fine. The only thing is, it results in the Beach Ball of Death and the user interface becomes unusable. Of course there's the possibility to run it ...

Using Yahoo local search query for iPhone

I'm using yahoo local search in an iPhone app and trying to query everything in a certain location. According to the api docs you can pass "*" to query and it will return everything. I've tried passing it several different ways, including the way below but it does not work unless I actually pass it a real query. Does anyone know how or w...

CGContextShowTextAtPoint: invalid context

I want to call a method responsible for drawing text on screen after each 5 seconds. Here is my code -(void) handleTimer: (NSTimer *)timer { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGContextSetStrokeColorWithColor(context, currentColor.CGColor); CGContextTranslateC...

iPhone: Cocos2d how to make a sequence

I have two logos, which I want to come in after each other. I'd like to use CCFadeIn and CCFadeOut. I have Logo1, and then I want it to CCFadeIn, then I want it to stay for 2 seconds, then make it fade out using CCFadeOut, and then make Logo2 CCFadeIn for 1 second, stay for 2 seconds and then go away during 1 second with CCFadeOut. Ho...

NSUndoManager won't undo editing of a NSMutableDictionary

Hi, I'm experiencing problems with the undo operation. The following code won't undo an removeObjectForKey: operation but the redo operation setObject:ForKey: works. - (void) insertIntoDictionary:(NSBezierPath *)thePath { [[[window undoManager] prepareWithInvocationTarget:self] removeFromDictionary:thePath]; if(![[window undoManage...

Set Renderbuffer Width and Height (Open GL ES)

I'm currently experiencing an issue with an Open GL ES renderbuffer where the backing and width are are both set to 15. Is there any way to set them to the width of 320 and 480? My project is built up on Apple's EAGLView class and ES1Renderer, but I've moved it from the app delegate to a controller. I also moved the CADisplayLink outside...

iPhone UIView element similar to the lock screen

Does anyone know if there is an open source project for an UIView element that acts in a similar way to the lock screen for the iPhone. I am working on an app that has some sensitive data, and I want to add another layer of comfort for users, to be able to setup a 4 digit pin number on the app. I've seen apps like LoseIt and Weightbot ...

Create an XML file in iPhone app

Hi, I have a big problem. My program must save a Xml file with 3 float value (x, y, z of accelerometer) and a NSString value (name). How can I do? Thanks so much ...

How to force a textField to become editable?

I guess my description is not clear enough. So I'll try again: Imagine there is a ViewController, called Picture, that display two lines, Title and Description. In case the user tap one of the rows a new view controller is displayed, either Title or Description view controller. Each of these view controllers (i.e. Title or Description)...

How do I detect a remote pause (on headphones) vs. incoming call

I'd like to pause my app when the user pauses music on his headphones. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStateDidChange:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:[MPMusicPlayerController iPodMusicPlayer]]; works well. However, this is also triggere...

How hard is it for a .NET programmer to learn Objective C and Cocoa?

Hi, I'm trying to build a dual platform application for a company of my own I'm trying to start at night. I have the .NET version done, but have not finished the UI part. I'm thinking of buying some 3rd party controls. If I buy these controls, however, they clearly will only work in my Windows version. I'm wondering if I should try ...

Passing array to another class - Objective C

I manage to pass the following array from MessagesTableViewController.m to arraySelectedCategory in another class called MessageDetailViewController.m: self.messageDetailViewController.arraySelectedCategory = [[NSMutableArray alloc] initWithObjects:@"Value 1",@"Value 2", @"Value 3", nil]; but how do I hand over an array stored...

Proper use of UIApplicationMain

I have decided to load my views programmatically, so putting: int ret = UIApplicationMain(argc, argv, nil, nil); Would not work. I do have a ViewController and an AppDelegate, though. What would be the proper use of UIApplicationMain to use a ViewController and an AppDelegate. PS I am NOT using XCode or Interface Builder, I am develop...

Make a call in Objective C help!

I need to make a call where it says add call here. Can someone help? - (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)ntype { NSLog(@"Scheme: %@", request.URL.scheme); if ([request.URL.scheme isEqualToString:@"save"]) { ...

UIGraphicsBeginImageContext question in Objective C

I need the UIGraphicsBeginImageContext(self.view.frame.size); changed to where the .frame part pulls from webView - (void) save { UIGraphicsBeginImageContext(self.view.frame.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraph...

setContentOffset only works if animated is set to YES

I have a UITableView which I would like to be displayed 100px down. For some reason this only works when animated is set to YES. Why is this? - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; /*[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atS...