objective-c

Objective-C equivalent of Actionscript code

Can anyone help convert this this actionscript to Objective-c? if(mcMain.y >= stage.stageHeight - mcMain.height) { mainJumping = false; mcMain.y = stage.stageHeight - mcMain.height; } Specifically the stage.stageHeight and mcMain.height? ...

Moving every object in my array ?

I have an array an a timer that adds a new object to my array every 5 seconds but am running into a slight issue. I have a code that is called repeatably which moves the objects in my array but for some reason the previous object that spawns will stop moving when a new object is spawned into my array. How do I make it so every single obj...

Iphone, objective-c how to make a Jump method for a platformer

I have this IBAction that is suppose to make a character onscreen jump, however when its called it just moves the character up once, then each call after that the character just moves down more and more. This function should just be called then the character would 'jump' up and then fall straight down off the screen since i havent put i...

Xcode question: Quickly jump to a particular selector/class/symbol ?

What is the quickest way to jump to a particular symbol/selector/class in Xcode? (I'm looking for keyboard shortcuts preferably). Right now, I know two ways of doing this: “Open Quickly” > Click on the Symbols dropdown menu at the top of the editor > Select the selector to jump to it. Click on “Project Symbols” in the “Groups and File...

Two Dimension NSMutableArray help?

Ok, I have some C# code that looks like this and I was wondering what other developers would recommend if I am trying to put this into Objective-C. List<List<string>> meta_data I'm planning on using NSMutableArray but how to exactly get that two-dimensional array figured out is my problem, since there is no such thing as a multidimens...

Difference between [[NSMutableDictionary alloc] initWithObjects:...] and [NSMutableDictionary dictionaryWithObjects:...]?

Still learning Objective-C / iPhone SDK here. I think I know why this wasn't working but I just wanted to confirm. In awakeFromNib, if I use [[NSMutableDictionary alloc] initWithObjects:...] it actually allocates (iPhone) system memory with this NSMutableDictionary data, but when I use [NSMutableDictionary dictionaryWithObjects:...] it ...

Testing Nested Error Handling with OCMock

I'd really appreciate some advice around testing for errors using OCMock. Method Under Test It grabs a process using an instance of the AppScriptController class. @implementation ProcessGrabber -(void)grabProcess { NSError *error = nil; NSString *processName = [appScriptController processName:ProcessRef ...

Saving a Single int into NSdefaults

I've been searching around for tutorials on how to save certain things to NSuserdefaults but have only found stuff mostly dealing with arrays and strings. Can anyone lead me to or give some person knowledge about saving and loading a int. For my application I have my int highScore = 0; but I want it to save this int into your NSuserdefau...

Is it possible to use Objective-C runtime features to determine where a method was called from?

Objective-C uses a sophisticated message-passing system when one object calls a method on another object. I want to know if it is possible, within the called method, to determine what the calling object was? For example: @implementation callingClass - (void)performTest { calledObject = [[[calledClass alloc] init] autorelease]; ...

Document Directory in iPod Touch and iPhone

Hello, I'm designing an application that reads data to the iPod touch/iPhone that is sent to it via multicast sockets with UDP and I need to store it as a file in a document directory. Does that exist on on the iPhone or iPod Touch? I know there is NSFileHandle and NSFileManager, which is what I plan on using, to take care of reading and...

How do you enable javascript in a WebView

I have a very simple Mac Cocoa app that just has a Web View that loads an HTML file with some CSS and JavaScript. I have hooked up the app delegate to this method: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSString* filePath = [[NSBundle mainBundle] pathForResource: @"index" ofType: @"html"]; NSURL *ur...

Can I declare variables inside an Objective-C switch statement?

I think I'm going blind, because I can't figure out where the syntax error is in this code: if( cell == nil ) { titledCell = [ [ [ TitledCell alloc ] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier ] autorelease ]; switch( cellNumber ) { case 1: NSString *viewDataKey = @"Name"; etc... When I try to...

What does this syntax error mean?

i got 3 syntax errors: "syntax error before "}" token" my code was IBOutlet UITextView *fruitDescription } "syntax error before "{" token" my code was - (void)viewDidUnload { "syntax error before "{" token" my code was - (void)dealloc { Any ideas? ...

How do I manually call a UIView's touch event on the iPhone?

How do I manually touch a UIView means programattically. I want to touch a view inside a UIScrollView touch manually. Any idea how to do this? Or how do I manually call UIScrollView's scrollViewWillBeginDecelerating? ...

iPhone: scroll table view cell to visible above custom keyboard-aligned toolbar?

I've been asking a question or two over the past few days of working on an application that keeps a custom toolbar aligned to the top of the iPhone keyboard. I'm using the method described by Josh in this question; basically, I have the view controller listen for the UIKeyboardWillShowNotification and add the toolbar as necessary. The v...

why wont it recognize the @properties from header file from main file?

UIView.h #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> @interface UIView : UIResponder { IBOutlet UILabel *endLabel; IBOutlet UIButton *goButton; IBOutlet UITextField *textBox1; IBOutlet UITextField *textBox2; @property(nonatomic, retain) UILabel *endLabel; @property(nonatomic, retain) UIButton *goB...

Is there something like Matlab's eval statement in Objective-C 2.0?

I am new to Objective-C and I am looking for an eval statement like I have used in Matlab. If you are not familiar with this, you can build a character string and then eval that string, which treats it like it is a line of code. Here is a example where you would want to change the background color of one of a series of 4 buttons base...

NSMutable Dictionary adding objects

Is there a more efficient way to add objects to an NSMutable Dictionary than simple iteration? Example: // Create the dictionary NSMutableDictionary *myMutableDictionary = [NSMutableDictionary dictionary]; // Add the entries [myMutableDictionary setObject:@"Stack Overflow" forKey:@"http://stackoverflow.com"]; [myMutableDictionar...

iPhone Programming setNeedsDisplay not working

Implemented my own drawRect method and I'm trying to redraw the shape from a Controller class and I can't figure out how to correctly implement setNeedsDisplay to redraw the UIView. Please help!! I know the code is ugly, but here is the custom method: - (void)drawRect:(CGRect)rect{ // Drawing code NSArray *kyle = [self pointsForPolygo...

Instruments (Leaks) and NSDateFormatter

When I run my iPhone app with Instruments Leaks and parse a bunch of NSDates using NSDateFormatter my memory goes up about 1mb and stays even though these NSDates should be dealloc'd after the parsing (I just discard them if they aren't new). I thought the malloc (in my heaviest stack trace below) could become part of the NSDate but I a...