objective-c

Objective-C Problems with NSDictionary and NSURL

Hi, I am new to Objective-C and I have no clue why this code is not working: NSMutableDictionary *bookmarks = [NSMutableDictionary dictionaryWithCapacity:(NSUInteger) 4]; [bookmarks setObject:@"Stanford University" forKey:[NSURL URLWithString:(NSString *) @"http://www.stanford.edu"]]; [bookmarks setObject:@"Apple" forKey:[NSURL URLW...

Method calls and declarations in objective-c for cocos2d-iphone

I am an absolute objective-c, c, and openGL newbie. Hence, when I found coco2d I was pretty thankful for having a lot of stuff done for me. Regardless, I'm still having issues. After I managed to get an animated sprite moving around based on touches I decided to clean up my code a bit into a updateLogic method and than a updateDrawing ...

Double releasing when it shouldn't be happening

I am really puzzled by this. I believe I am managing memory the correct way but executing the code suggests that I am double releasing the object. Here is the code and then I'll explain what is happening. @protocol SomeDelegate <NSObject> @required - (id)initWithCols:(NSUInteger)Cols Rows:(NSUInteger)Rows; @end @interface SomeObject :...

Calling Objective-C method from C++ method?

Hi, I have a class (EAGLView) which calls a method of a C++ class without problems. Now, the problem is that I need to call in that C++ class a objective-C function [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer]; which I cannot do in C++ syntax. I could wrap this Objective-C call to the same Objecti...

objective-c question regarding NSString NSInteger and method calls

I like to create an instance of a custom class by passing it a value that upon init will help set it up. I've overridden init and actually changed it to: - (id)initWithValue:(NSInteger *)initialValue; i'd like to store this value in a property of the instantiated object and use the value to generate the filename of a UIImage that will...

Problem with UItableview reload data using alert view with prompt on a custom cell.

I have a UItableViewController with a custom cell designed using interface builder. The custom cell has a button and a label on it. The button when click will trigger an alert view with prompt. Once the text is entered and press OK the label on the cell will display the updated info on the table. The problem is the label will not get upd...

iPhone 3.0 SDK vs iPhone 2.0 SDK

Hi, is iPhone 3.0 SDK significantly different that I cannot use any books that were meant for iPhone 2.0 SDK? Programming is pretty much the same? ...

Objective-C: What's the Difference between objectForKey and valueForKey?

What is the difference between objectForKey and valueForKey? I looked both up in the documentation and they seemed the same to me. ...

Enforcing that a class posts a particular NSNotification?

Is there any way to ensure that a class posts a particular NSNotification? (I have a set of classes, and I would like to enforce at compile-time (if possible) that the class posts a required NSNotification). Alternatively, if that is not possible, is there any workaround? ...

how to disable vertical scrolling of scrollview iphone?

i have a view like iphone's springboard . i created it using a scroll view and buttons.i want to disable horizontal scrooling on that view.i want only vertical scrolling.how do i do this? ...

How do you programmatically put folder icons on the Finder sidebar, given that you have to use a custom icon for the folder?

Am currently working on a project, and though I can add sidebar items by adding to the com.apple.sidebarlists.plist file then restarting Finder, I can't seem to know how to make the folder icons show up using its assigned custom icon. Can anyone point me to a link or a solution that would make me do this? Thanks a bunch in advance! ...

Why does a custom UIButton image does not resize in Interface Builder?

Why does a custom UIButton image does not resize with the button? I set it's view mode to Scale to Fill in Interface Builder, but unlike a UIImageView image, it doesn't respect that setting. Am I looking in the wrong place or is it not possible? ...

Use NSArrayController with nested NSMutableArrays (Cocoa Bindings Question)

Hi, I have a NSArrayController with following Object: @interface AdressCard : NSObject <NSCoding> { NSString* name; NSString* street; NSMutableArray* tasks; } I have a simple GUI with an NSTableView to display the first two keys and I want to have a second NSTableView to display the content of the MutableArray (tasks) for...

scrollsToTop not working

I have the following object structure: UITabBarController UINavigationController UITableViewController It used to work, but then I added the UITabBarController into the mix and made a bunch of other large changes and somewhere in between it stopped. So far I have: created a new project with that structure, and that seems to wo...

Objective C Static Class Level variables

I have a class Film, each of which stores a unique ID. In C#, Java etc I can define a static int currentID and each time i set the ID i can increase the currentID and the change occurs at the class level not object level. Can this be done in Objective C? I've found it very hard to find an answer for this. ...

Is it possible to alter the letter-spacing/kerning of a font with Cocoa Touch?

I've been scouring the Internet for a while now for information on how one can alter the letter-spacing/kerning of a font within UIKit. My fear is, that like using your own custom fonts, you simply can't. Which would be terrible news. I know Apple is protecting us from bad design with these constraints, but they're also preventing us f...

How to safely pass a context object in an UIAlertView delegate?

In my application I use a UIAlertView to display to the user a message and some options. Depending on the button pressed, I want the application to perform something on an object. The sample code I use is... -(void) showAlert: (id) ctx { UIAlertView *baseAlert = [[UIAlertView alloc] initWithTitle: title ...

Objective C class initialization errors

I have the following objective C class. It is to store information on a film for a cinema style setting, Title venue ID etc. Whenever I try to create an object of this class: Film film = [[Film alloc] init]; i get the following errors: variable-sizedobject may not be initialized, statically allocated instance of Objective-C class "Fil...

Is there a way to specify argument position/index in NSString stringWithFormat?

C# has syntax that allows you to specify the argument index in a string format specifier, e.g.: string message = string.Format("Hello, {0}. You are {1} years old. How does it feel to be {1}?", name, age); You can use arguments more than once and also omit arguments that are provided from being used. Another question mentions the same ...

GKSession Problems - Objective-C GameKit

Ok, I've been trying to create my own GKSession object and the delegate method is giving me an error in the console that I haven't figured out how to fix just yet. I was wondering if anyone had any suggestions or had encountered this problem? *Just a note - the variable peerStatus is defined elsewhere in my code. The peer can either be g...