objective-c

Do I need to add <UIAlertViewDelegate> protocol?

I have added an alertView to display an alert message to the user (see below) -(void)connectionAlert { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" message:@"<Alert message>" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; [alert...

Using installed identity certificate from within an app on iPhone

Hi, My question is: is there a way to use the installed identity certificates on the phone from within my app. For example similar case like with Safari: if certain site requires client certificate, the user has to install it on the phone and then when authenticating Safari uses the installed certificate to authenticate. I need to do th...

GNUStep make with a precompiled (and prefixed) .pch header from Xcode project?

I'm trying to build an Xcode project with GNUStep-make. Right now the project is very small (3 classes) however it will grow to hundreds of classes over the coming weeks so I'm trying to get everything figured out and well-organised now. Xcode creates a ProjectName_Prefix.pch file which is a header that: a) get precompiled and b) is pr...

iPhone - Change entity class (NSManagedObject) to make them initializable

Hi everyone, I would like to use my custom NSManagedObject like a normal object (as well as its regular functions). Is it possible to modify the class in order to be able to initialize it like a normal object? [[myManagedObject alloc] init]; Thanks edit: to clarify the question, will it screw everything up if I change the @dynamic w...

How to compare two times in milliseconds precision?

I have a subtitle text file that works with standart srt format 00:00:00,000 Hour, minutes, seconds, milliseconds. I want to create a timer to update the subtitle screen and check the current time to know what subtitle show on screen. Which is the best to use? NSTimeInterval, NSDate? I think the best is to convert all to times to mil...

NSOutlineView/NSTreeController - calculate sum of column

I have an NSOutlineView bound to an NSTreeController. My data items are a custom class, let's call them Row, and suppose a Row contains a name and a numeric field called number. All these Rows are found in let's say a RowContainer which has a rows mutable array holding the parent (level 0) rows. Each row also has a children NSMutableAr...

How can i use a variable created in a objective c Void function?

Im trying to get the lat and long values generated in a void function and use them within another function. Any help grateful. - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { float latDeg = newLocation.coordinate.latitude; NSLog(...

How to sort an NSMutableArray of objects by a member of its class, that is an int or float

I have a class (from NSObject) that contains: NSString name int position float speed I then create an array (NSMutableArray) of objects from this class. I would like to then sort the array by the 'speed' value, which is a float. I initially has the float value as an NSNumber and the int as NSInteger, and I was successfully s...

NSString stringWithFormat question

I am trying to build a small table using NSString. I cannot seem to format the strings properly. Here is what I have [NSString stringWithFormat:@"%8@: %.6f",e,v] where e is an NSString from somewhere else, and v is a float. What I want is output something like this: Grapes: 20.3 Pomegranates: 2.5 Oranges: 15.1 What I ...

Adding a NavigationBar to UITableViewController programmatically?

I am trying to create a uitableviewcontroller as a modal viewcontroller to edit some settings. I am creating the tableviewcontroller in code and the thing i am struggling with currently is how to correctly add a navigation bar to the controller which will have a "Done" button on it that: a) doesnt appear on top of the tableview and b) ...

Exception handling in Obj-C

I have been reading about exception handling on the Apple developer docs, but I was wondering why exceptions by standard C operations are not caught? E.g. the code below still crashes the application, without catching the div by zero. Will the @try/@catch block only catch Obj-C code? @try { int i = 10 / 0; } @catch (NSException * ...

Two UIViews in one .xib file?

hi, i made a second uiview in mei .xib file. the first view is landscape and i get it by following code ItemController *newItem; newItem = [[ItemController alloc] init]; newItem.view..... how can i "activate" the second view, so i can use it with newItem.view2... is that possible? the second view is portait mode, so it should be h...

Get String Instead of Source - Xcode Cocoa

Hello everyone, I have a program that will scan the contents of a website, and display it in a textbox. The problem is that it shows the html source. For example if my html code was: <html> <body> <p>Hello</p> </body> </html> instead of just showing hello, it'll show the code above... How can I get my objective c program to just ...

Getting a color value from an image

Right now I am using a bitmap array to get a specific pixel color value from a UIImage. I couldn't find anything online other than the code from here: http://www.markj.net/iphone-uiimage-pixel-color/) Which works well enough. I wanted to know if there are any other ways to get the color for an image. Looping through myself feels a littl...

String Formatting Tricks/Docs

Was reading the response by Shaggy Frog to this post and was intrigued by the following line of code: NSLog(@"%@", [NSString stringWithFormat:@"%@:%*s%5.2f", key, padding, " ", [object floatValue]]); I know string formatting is an age old art but I'm kinda doing the end around into Cocoa/Obj-C programming and skipped a few grades alo...

Predicate for searching the first letter of each word in a string of words

I would like to create a predicate to search for a specific letter at the start of each word in a string of words e.g. all words starting with A in @"The man ate apples", would return ate and apples. Is it possible to create such a predicate? Thank you. ...

Get current UIViews?

is there a way to get the current UIView object, which i defined in - (void)viewDidLoad to use/change them in another method in the same .m file? thanks ...

How do I see when an object is influenced, and by what?

Hey SO, This might be a long shot, but I'm having a bug that I'm fairly sure is specific to my program. I'm animating something, and between then the animation starts and stops, something is influencing my animated view, and changing it's size. I was wondering if there was a way in the debugger, or really in anything to see what's inf...

How switch UIViewController by flip from 3 controllers ?

Hello, all. I've got next problem: i've got 3 UIViewController and need to switch controllers by UIModalTransitionStyleFlipHorizontal. Next code working fine: testController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:testController animated:YES]; where testController - next control...

I need help to debug my XML parsing please

I'm parsing this line: <type>branch</type> with this code in didEndElement if ([elementName isEqualToString:@"type"]) { [currentBranchDictionary setValue:currentText forKey:currentElementName]; } When I test the value in the type key, it does not contain branch but instead it contains branch\n. Here is the test I'm ...