objective-c

cocoa: know the position of the app icon in the dock

Hello, I need to show a special menu when the dock icon is hovered. In order to do this I need to find a way to get the coordinate of the app icon in the dock. Do you know how I can get this info? Thanks and regards, ...

How can I optimise out this nested for loop?

How can I optimise out this nested for loop? The program should go through each word in the array created from the word text file, and if it's greater than 8 characters, add it to the goodWords array. But the caveat is that I only want the root word to be in the goodWords array, for example: If greet is added to the array, I don't want...

Detect when the finger lifts after a UISwipeGesture[Recognizer]

I've set up a UISwipeGestureRecognizer: UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:delegate action:@selector(handleSwipeGesture:)]; swipe.direction = UISwipeGestureRecognizerDirectionUp; [self addGestureRecognizer:swipe]; [swipe release]; A swipe makes the player move in the direction of the swi...

Accessing ivars of an objective-c class within c++ function

I have an objective-c class, which has a string ivar which I need to change when a callback function is called. The trouble is that the callback is in c++, and I therefore cannot access the ivars of the objective-c class in that c++ function. The callback must be in c++ that, cannot change. I realize that there are other ways this could ...

Objective C - NSDictionary Question

Hi I am a newbie to objective C and was wondering how I could form an NSDictionary with the following structure. level 1     level attribute 1.1 - level score - level percent     level attribute 1.2 - level score - level percent     level attribute 1.3 - level score - level percent level 2     level attribute 2.1 - level score - level ...

appleevent versus notification

Hello, I am looking for a high performance inter process communication system in macos X. What is the best system? AppleEvents or NSNotifications? Thanks :) ...

Understanding the bitwise AND Operator

Hello, I have been reading about bit operators in Objective-C in Kochan's book, "Programming in Objective-C". I am VERY confused about this part, although I have really understood most everything else presented to me thus far. Here is a quote from the book: The Bitwise AND Operator Bitwise ANDing is frequently used for masking operat...

Disable touches on UIView background so that buttons on lower views are clickable.

Hi There, Basically, here is my view hierarchy (and I appologize if this is hard to read... I'm new here so posting suggestions happily accepted) --AppControls.xib -------(UIView)ControlsView ----------------- (UIView)TopBar ----------------- -------------- btn1, btn2, btn3 ----------------- UIView)BottomBar ----------------- -...

How to remove a subview if triggered from one of its components?

I'm looking for a smart way to remove a subview (with removeFromSuperview) when the subview itself (or precisely said one of its components) triggered the removal. As for the source code this would be like UIView * sub_view = [[[UIView alloc] initWith... UIButton *button = [UIButton buttonWithType... [sub_view addSubview:button]; [se...

iPhone/Objective-C array enumeration crashes

This is a bit complex. I've created an array (NSArray) called pointsOfInterest. The elements of this array are NSDictionary objects. Each dictionary has two keys, "headerTitle" and "rowObjects." The value for "headerTitle" is a simple NSString; the object for "rowObjects" is another NSArray of objects; each of these is a custom class. ...

Objective C - MapKit

Hi, I'm using a MapView. It works fine on the simulator but when I test on a device, the map doesn't seem to load. (or does load but takes a very long time sometime). All I do to use the MapView is just grabbing an instance on MapView and put it in the view through Interface Builder. Is there anyway I can do to force the map to load? ...

Objective C Math Formula Fail

Hi, noob here wants to calculate compound interest on iPhone. float principal; float rate; int compoundPerYear; int years; float amount; formula should be: amount = principal*(1+rate/compoundPerYear)^(rate*years) I get slightly incorrect answer with: amount = principal*pow((1+(rate/compoundPerYear)), (compoundPerYear*years)); I'm...

When dealloc is called in objective-c

If i create a simple class like this @interface table : NSObject { NSMutableArray *array; } @end and in the Init method I call: array = [[NSMUtableArray alloc] init]; and in the dealloc method I call: [array release]; but I have a memory leek because the dealloc method is never called. I must call the dealloc method by myself? ...

MapKit - drawing lines between 2 pins

Hi, How can I draw lines between 2 pins on the MapView? Thanks, Tee ...

NSString is really Immutable?

Why when I code I can do: NSString *test; test = @"stack"; test = @"overflow"; without any problems, NSString is not supposed to be immutable? ...

How can I save a simple counter in an iphone application such that I can increment is and the change will be saved between application launches?

All I want is an integer which everytime my app opens is incremented by one. Is there an easy way to do this? Please help. Thanks, in advance. ...

Entity is not key value coding-compliant for the key - Objective-C/CocoaTouch/CoreData

if (win) { // Game was won, set completed in puzzle and time // Calculate seconds taken int timeTaken = (int)([NSDate timeIntervalSinceReferenceDate] - self.gameStartTime); int bestTime = [[self.puzzle valueForKey:@"bestTime"] intValue]; if (timeTaken < bestTime && bestTime != 0) { [self.puzzle setValue:[N...

Toggle UIButton on the iPhone

How can I make a button that says "Show Picture" and when it's clicked it changes to "Hide Picture". I'm new to objective C, I know how to make a button in interface builder but don't know how to switch the button's text and function. Can someone help me out? ...

NSString cut - Length of NSString in Core Data - Objective-C iOS 3.2

Hi, I want to save the filePath of an ImageAttachement in Core Data. The method addNewImageAttachementWithFilePath creates a new ImageAttachement and registers this at Core Data. Now I have the problem that the filepath is cut when the filepath of the imageAttachement is set. - (void) addNewImageAttachmentWithFilePath:(NSString *)fil...

How to call objective-C function from a C function

I'm trying to call an objective-C function from a C function but the code keeps crashing in objc_msgSend. My objective-C class is a singleton and I'm using the following code. void c_function(int arg0, const char *arg1) { [[objc_class instance] testFunction:arg0 Arg1:arg1]; } The gdb shows the crash is happening when object...