objective-c

Programmatically defining NSSegmentedCell

I am a little stumped as to how to instruct a programmatically created NSSegmentedControl to use a subclass instance of an NSSegmentedCell. If I want to use a subclasses NSSegmentedCell on an NSSegmentedControl built using IB it would be as simple as doing the following: Drag an NSSegmentedControl into the NSView Click through to the ...

convert instance variable into string?

Hi, if I have a uiviewcontroller with a instance variable "direction". I can do MyViewController.direction but if I don't want the value but a string with the variable name, so I want @"direction". Is it possible? thanks, alex ...

CFURLCreateDataAndPropertiesFromResource failed with error code -15

I'm trying to lead a TIFF image into a CGImageSource using CGImageSourceCreateWithURL. My URL is correct, is %20 encoded, is a path to an existing file, that file is a TIFF. However, the line: NSString *fullPath = [[[fileNames objectAtIndex:pageNum - 1] string] stringByAddingPercentEscapesUsingEncoding: ...

How to release a variable that is about to be returned?

I stumbled into a problem when I hit the "build and analyze" button on the Build menu in my Xcode. The analysis suggest me to release a variable that I wish later on to be returned. The code is like following: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{ //I do some other th...

How to diagnose a KERN_PROTECTION_FAILURE

I am getting an interesting crash that I can never seem to replicate on the simulator: Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000008 Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x3212e86c 0x3212c000 + 10348 1 StockTwits 0x00016b06 0x10...

iOS app, classes suddenly vanish, crash in alloc

This is a weird one. On and off as I have been working on my application, this problem has popped up, and then it has always mysteriously vanished. Today it is refusing to vanish. My app uses two view controllers to handle auto rotation. Sometimes, Objective-C can't find my classes. For example [OneViewController alloc] will crash. ...

Can canceling a NSURLConnection lead to problems?

Before my view loads I call: [theConnection cancel]; //assume theConnection is an NSURLConnection I then proceed and make my proper NSURLConnection. Will calling cancel before a connection is even made cause any problems? ...

Document directory structure after Updating version of the application

What is Document directory structure after Updating version of the application ? is it replacing old with new Document Folder ? or it is just updating document folder ? please help.... ...

How do I replace a string with a string of unknown length?

I'm building a To-Do-List application which uses the following objects: NSTexField for data entry NSTableView to display the data (just string objects) NSButton that when clicked will add the contents of the NSTextField to the NSTableView for display. What I want to do is replace any given string in any row in the NSTableView with an...

Changing UINavigationController from UItabBarController

Hello!, I have a tabBarController with 4 tabs. In the fist one I need to show an UINavigationController which has a UIView in it. When the user presses a button inside that view I need to display another UINavigationController in tab 1 replacing the old one. Is this possible? I tried using this code with no luck UINavigationController ...

Property not found even with import

I have a property called currentViewController which I declare in my DetailViewController as: @property (nonatomic, assign) UIViewController *currentViewController; and import it in my MasterViewController. For some reason the class is not seeing this property unless I explicitly cast it: ((DetailViewController *)detailViewControlle...

How to show Hi-Res stretchable backround image in UIButton?

Hi. I'm setting up a custom button with an oval background image in UIView. In iPhone OS 3, [UIImage:stretchableImageWithLeftCapWidth:topCapHeight:] works fine. But, in iOS 4 with iPhone 4 (means Hi-Resolution), the background image doesn't stretch out. Here's the code in question: UIButton* btn = [UIButton buttonWithType:UIButtonTyp...

PHP's strtotime in Objective C/iPhone

Is there an equivalent (or vaguely similar) to PHP's strtotime in Objective C/iPhone? strtotime can for example understand the below time expressions (from the php documentation): echo strtotime("now"), "\n"; echo strtotime("10 September 2000"), "\n"; echo strtotime("+1 day"), "\n"; echo strtotime("+1 week"), "\n"; echo strtotime("+1 ...

Objc memory problem at arrays

Hello guys! Here's my code: NSLog(@"rc: %d", [_pagesButton retainCount]); NSMutableArray *anArray = [[NSMutableArray alloc] initWithArray:_toolbar.items]; NSLog(@"rc: %d", [_pagesButton retainCount]); [anArray removeObjectAtIndex:2]; NSLog(@"rc: %d", [_pagesButton retainCount]); [_toolbar...

Objective C - Number to String and Grab length inconsistencies

I am trying to grab a number from a text box entry, convert it to string and grab the length of it. (IE: Perform a LEN(someInteger) on a number). I have been able to get it working, however there are some inconsistencies when the number is 0 or null. For example; -(IBAction)update { // inputField is the number pad textbox doubl...

How to Get System Color in iphone?

I have used following code to set background color [self.view setBackgroundColor:[UIColor groupTableViewBackgroundColor]]; but it results into black background instead faint lining blue? Where am i going wrong? so how to get proper groupTableViewBackgroundColor? ...

Get hit test event type

Hi, Is there a way to know if the hitTest:withEvent: method is being thrown because of a touchesBegan, touchesMoved or touchesEnded event? by now I only do: if([event type]==UIEventTypeTouches) { } but this is not exclusive enough ...

send the user input to url and fetch the result and display it in the program in cocoa objective c

hi, I am writing a program that would allow for online currency exchange on a MAC, I wanted to use the information on www.xe.com . I was wondering if A) if it would be possible for me to do that. and if yes the B) if it would be possible for the program to send the user input to the website and then fetch the result and display it in ...

How to always visible scroller of Tableview in Obj c?

Hi I want to show user there is a more content below but UITableView only shows scroll indicator when we scroll the tableview. There is any way, so I can show scroll indicator always ...

Memory problem with properties in objective-c

Hello guys! UIImage *image = [[UIImage alloc] initWithData:data]; ((YKSubCategory *)[_subCategories objectAtIndex:connection.tag - 1]).menuImage = image; [image release]; Here is the code I've written. The data is exists and the designed image is created. (I've tested it with an imageview and the image appears). The problem comes when...