objective-c

How can I update the MKMapView?

I can use this method to show my location at first. -(void)displayRegion:(double)latitudeDouble: (double)longitudeDouble{ CLLocationCoordinate2D coord = {latitude: latitudeDouble, longitude: longitudeDouble}; MKCoordinateSpan span = {latitudeDelta: .005, longitudeDelta: .005}; MKCoordinateRegion region = {coord, span}; ...

Resize and saving an image to disk in Monotouch

I'm trying to resize an image loaded from disk - a JPG or PNG (I don't know the format when I load it) - and then save it back to disk. I've got the following code which I've tried to port from objective-c, however I've got stuck on the last parts. Original Objective-C. This may not be the best way of achieving what I want to do - any...

Static variable scope within class?

Can anyone tell me what the scope of the static variable in the class below is? @implementation SharedManager static id myInstance = nil; +(id)sharedInstance { if(myInstance == nil) { myInstance = [[self alloc] init]; } return myInstance; } In a test I created an instance from the class and then released it, but ...

Mike Ash Singleton: Placing @synchronized

I came accross this on the Mike Ash "Care and feeding of singletons" and was a little puzzeled by his comment: This code is kind of slow, though. Taking a lock is somewhat expensive. Making it more painful is the fact that the vast majority of the time, the lock is pointless. The lock is only needed when foo is nil, which ...

Detect what's being inputed in a UITextField

Hi. I have a UITable View with a textfield that is editable right on the view (like Phone in contacts, etc.). I want to enable/disable my save button conditional up text being present in this field. So, I want the button to start out as disabled (for a new record) and then, as soon as I type the first letter into my text field, I want t...

Is this a valid use for blocks in Obj-C?

In my constructor, I want to create a random color. Therefore, I need three random 7-bit floats in the range of 0…1 that make up the red, green and blue component of the color. Instead of writing the rather long random() % 128 / 128.0 three times, I put that in a block: CGFloat (^randFloat)() = ^(){ return random() % 128 / 128.0; }; co...

Objective-C : Start an object on a background thread -- interact as usual?

I would like to have an object be callable from the main thread MyObj* backgroundObject = [[MyObj alloc] initInBackground]; BOOL result = [backgroundObject computeResult]; But have all the methods of backgroundObject compute in another thread. And also have backgroundObj be able to send messages to it's delegate. How can I do such a ...

What is the best way to store data in an objective-c model?

I am writing an objective-c model to hold all of the data parsed from an XML connection. I am using an NSURLConnection to download the data asynchronously and it is then passed to the parser. I have done this before, but not with such a large xml file. I would like to garner some opinions on the best way to store the data. Here are s...

Create a re-sizable array of CGPoints in objective-c

Hi I am trying to create a re-sizable array of CGPoints in objective-c. I've have looked into using NSMutableArray however it doesnt seem to allow resizing. Is there something else I can use? thank you ...

iphone error when unit testing: Expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

I get the following error when I try to build (Build->build) a unit test. My unit test is a logic test (it does not run on the device). Things that are probably related to my problem are: I am using libxml2 and a wrapper around it (which i found at cocoawithlove). This wrapper has some C functions defined (it is not an Objective C cla...

NSPredicateEditorRowTemplate for date comparison

I'm building an NSPredicateEditor, and I want the ability to do advanced date comparison. I realize that I can build an NSPredicateEditorRowTemplate with a rightExpressionType of NSDateAttributeType, but the predicates I want to build need to be much more advanced than that. For example, I need to basic comparison like: dateKeypath <...

How do I rotate from landscape to portrait upon loading a view?

Hello everyone: I'm working on a module for a project where the screen is in landscape mode when I get it. I have to load a new view, and switch to portrait mode. While this seems simple enough, I have not been able to find a simple solution. Here's what I tried: [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOri...

How to convert Objective C textual (po) representation to real object

Hi, In xcode you can use po object to see a textual representation of a given object. Is it possible to convert from this textual representation to a real objective c object? Thanks ...

How to resize UITableViewCell Background in editing mode

Hi I've a table view with a custom image background of each cell. In normal mode the background is perfect and fill all the cell. When tableView enter in editing mode the "-" button appear on left and all the object are indented and in the left I've problem with background: there a white area. Can anyone help me? The background image is...

How to use NSPredicate to catch child objects?

I'm new to core data and try to get all children objects of various types with one query. Say there's an "Animal" type as parent and "Cat", "Dog" and "Bird" as children. I'd like to get both cats and dogs, but not Birds in single query returned as Animal objects. Is it possible? ...

Strange memory management issue

I can't identify the object being deallocated, I run my app with Command+Y but despite having MallocStackLogging set to YES and NSZombieEnabled set to YES, when I hit EXC_BAD_ACCESS in my app, gdb doesn't print the memory address of the deallocated object. Any ideas? Apologies if this seems vague, it looks like it's Core Data related, ...

UIView transitions present modal view at the bottom

I need to display a UIView/UIViewController when the user taps a button and the modal view should appear just like how the key board appears from the bottom bar when you edit text in a UITextField. Using the following code, I get to show it as a pop up. [self presentModalViewController:child animated:YES]; How to make it appear like ...

Compare NSArray with NSMutableArray adding delta objects to NSMutableArray

I have an NSMutableArray that is populated with objects of strings. For simplicity sake we'll say that the objects are a person and each person object contains information about that person. Thus I would have an NSMutableArray that is populated with person objects: person.firstName person.lastName person.age person.height And so on. ...

NSStream, NSError, error code

Hi, I'm developing small FTP upload app. for mac (10.6 if it matters) Have problem with NSStream, actually I cannot understand how to find our error by its code. NSError code=14 domain=NSPOSIXErrorDomain Where to check what does 14 means? Thank you. Just in case here is my code (maybe you can also tell me why I have an error) NS...

is it possible to decode special HTML entities in Objective C (for iPhone)?

could you show me algorithm for implement decode special HTML entities in Objective C? any idea? ...