objective-c

How to create a strategy pattern in Objective-C?

Hi, I need to develop a strategy pattern where i have a main class with other three classes where i need to refer to the objects of the other three classes using the main class object.To solve this is the strategy pattern will help me? If so please do give me the syntax in Objective-C? ...

Objective-C Overlay third-party map with GPS

Is it possible to overlay a third-party map and use the iPhone's GPS services? That is, for example, I have a street map of my own and want to use the GPS to track where I am in relation. Is this possible? Further, if so, are there any examples out there? ...

Changing an xcode project Path with lowercase path issue

I have a problem with an Xcode project which has a path of "/users/me/blah" with a lowercase 'u'. When I check my other projects (in the General Tab of the Project Info Window the Path starts with a uppercase "Users". This causes a couple of problems. When I try and add an existing file which is "relative to group" or "Relative to Proje...

What is the correct way to Manage memory in an iPhone app for an instance variable that is frequently reassigned to newly allocated memory?

I'm having trouble figuring out how to manage memory for an instance variable that needs to maintain it's current state for a period of time, then be reassigned to newly allocated memory. Take the following example for the instance variable "importantData".: -(void)Update { importantData = [[self getObject] retain]; } - (SomeObjec...

Pass events to UIScrollView

I'm trying to pass touch events from a UIImageView to a UIScrollView and it doesn't appear to be working. I've tried to define my screen elements below. Essentially, the overlaidImage will be the first to respond to all events. If a condition is met, I want it to handle the events. If not, I want it to be passed to the imageView and then...

Multiple Clipped Rects to Create Collage in Core Graphics

I am creating a collage combined with elements from other images. Here is some ASCII art to explain what I am doing: Given images A, B and C, AAA, BBB, CCC AAA, BBB, CCC AAA, BBB, CCC I take part of A, part of B and part of C as columns: Axx, xBx, xxC Axx, xBx, xxC Axx, xBx, xxC ...and combine them in one image like this: ABC ABC A...

Is it possible to create a CLHeading object in Objective C?

I'm trying to implement a drop-in location manager subclass to allow me to pass heading data to the iphone simulator, similar to the unimotion/accelerometer hack. Unfortunately, according to the CLHeading docs, everything is read only and there's no initialiser which allows the heading to be set. Is there a way to force the creation of a...

How can I make a UIButton perform my class method when tapped?

How can I make a UIButton perform my class method, +doSomething:(id)sender, on class MyClass, after any event like UIControlEventTouchDown? Can I use -addTarget:action:forControlEvents: like I do for instance methods? Thanks in advance. ...

loadView, didReceiveMemoryWarning, and an NSLock bug

I simulate a memory warning on the simulator. SettingsViewController releases it's view since it is not showing. I display the SettingsViewController view, loadView gets called, and then in viewDidLoad, the program hangs on the following line of code: self.unitSwitch.selectedSegmentIndex = 1; On my terminal, I get this message: -[NS...

How do I duplicate my xcode project? (iPhone SDK)

How do I duplicate my xcode project? (iPhone SDK) By the way, I simply duplicated/renamed the entire project folder. But when I started working in the new (duplicated) project (after changing app ids, provisioning profiles) I started getting errors about targets. I have no clue about what targets are or anything either so. Hmmm. Hope th...

iPhone unit test linking problem, can’t find DevToolsBundleInjection.framework

I'm trying to setup application unit tests for my iphone app. So I made a copy of the app target, and a unit test bundle target as described in apple's documentation. After following Apple's directions, I wasn't able to reference my classes in the unit tests, so I linked the app into the unit test bundle using the "Bundle Loader" build ...

Can you see anything wrong in this code? 'Cause I can’t, but it still doesn’t work.

// When row is selected - (void)pickerView:(UIPickerView *)pickerTimer didSelectRow:(NSInteger)row inComponent:(NSInteger)component { int minutes; int seconds; if (component == 0) { if (row < 0){ minutes = row; } else { minutes = 0; } } if (component == 1) { ...

Image resized error: CGBitmapContextCreate: unsupported parameter

I am using the following code (from a blog post) to resize an image if (inImage.size.width <= inImage.size.height) { // Portrait ratio = inImage.size.height / inImage.size.width; resizedRect = CGRectMake(0, 0, width, width * ratio); } else { // Landscape ratio = inImage.size.width / inImage.size.height; resizedR...

String to int - cocoa, objective-c

I'm trying to get a value from a NSTextField (Label) and convert it to a int... minFormatter = [[NSNumberFormatter alloc] init]; [minFormatter setNumberStyle:NSNumberFormatterNoStyle]; NSNumber *minTimeValue = [minFormatter numberFromString:[NSString stringWithFormat:@"%@", [self.minTextLabel stringValue]]]; [minFormatter release...

Cocoa switching a focus to my application

Hello, I have a statusbar application (the one that runs in the top bar of the system). When i click on the icon in the statusbar, a menu pops up and it has an item to configure my app. When i press this item, the main app window is shown [wndMain makeKeyAndOrderFront:self]; The problem is clicking a statusbar icon doesn't activate the ...

When to use objc_memmove_collectable directly in Objective-C code?

While looking for something else in header files and documentation, I recently discovered the following function prototype in <objc/objc-auto.h>: void *objc_memmove_collectable(void *dst, const void *src, size_t size); It's in the middle of a group of functions following a comment that says "Write barriers. Used by the compiler". The...

Speeding up or eliminating this slow function in an iPhone camera app

When you take photos witha UIImagePickerController on the iPhone, I and many internet denizens have found you need to run the images through this function to orient them properly (and scale them while you're at it). There is a giant thread about it here: http://discussions.apple.com/message.jspa?messageID=7276709 Unfortunately, this fu...

RC4 encryption - CommonCrypto (Objective-C) vs PHP

Hi, I have a XML file on a server encrypted with the RC4 algorithm (http://rc4crypt.devhome.org) function encrypt ($pwd, $data, $ispwdHex = 0) { if ($ispwdHex) $pwd = @pack('H*', $pwd); // valid input, please! $key[] = ''; $box[] = ''; $cipher = ''; $pwd_length = strlen($pwd); ...

UIImage animation

Hello guys! Maybe is there a way to do animation only on one image? So if I have an UIImage and I want to animate it like a wave. Is this possible? And if yes, can you give me some examples or a link to start or something like this? (I used google but didn't find any good start link...) ...

iphone Bluetooth Serial Port Profile stack implementation

Hi all... I am working on iphone app development(Objective C), I know that iphone only support Hands-Free Profile (HFP) and Headset Profile (HSP) bluetooth profiles.... I would like to know whether it is possible to implement bluetooth serial port profile(SPP) in iphone using objective C, so that i can communicate with other blue...