objective-c

How can I call a method in Objective-C?

I am trying to build an iPhone app. I created a method like this: - (void)score { // some code } and I have tried to call it in an other method like this: - (void)score2 { @selector(score); } But it does not work. So, how do I call a method correctly? ...

Objective-C memory issue (iPhone)

I'm somewhat confused by the following behavior I'm seeing within an Xcode project compiled for the iPhone simulator (or device): NSString *test = [[NSString alloc] initWithCString:"foo"]; NSLog(@"test retain count = %d", [test retainCount]); // prints 1 [test release]; NSLog(@"test retain count = %d", [test retainCount]); // also pr...

Custom RunLoop Mode

What am I doing wrong here? What am I missing? - (void)scheduleTimer { NSTimer *timer = [NSTimer timerWithTimeInterval:0.15 target:self selector:@selector(wtf:) userInfo:nil ...

Objective-C: Fixing memory management in a method

Hi all, I'm almost there understanding simple reference counting / memory management in Objective-C, however I'm having a difficult time with the following code. I'm releasing mutableDict (commented in the code below) and it's causing detrimental behavior in my code. If I let the memory leak, it works as expected, but that's clearly not...

Objective-C messaging, smartly dealing with unknown messages

Is there a way to do something similar to KVC but use the message name as the key itself? For example, rather than valueForKey:, is there a way for an object to respond to all messages? For example, say you have an XML document: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ...> <employees> <employee> <name>Bill</name> <de...

problem with declare a global variable in objective c

i have a global variable in 1 of the class like classA.h const NSString *global; classA.m global=[array objectAtIndex:0];//a array store sort of string and in another class i want to call this global variable classB.m import "class.h" NSLog(@"%@",global); but it doesnt work,i know when i jus assigned a value directly to my gl...

iPhone SDK: disabling cllipping for UIScrollView

Hi, I'm working on an iPhone game, and trying to use a UIScrollView to display some icons, which I then want to enable the user to drag off the bar being scrolled, onto another view (basically, dragging them from their hand into play on the game board). The problem is that the UIScrollView clips everything outside it's own bounds. Her...

Relationships in Objective-C classes

I'm really hesitant to ask this question, since it's sure to have such a terribly easy answer, but I just can't figure it out. Here goes: I have this Objective-C code in a file called Copier.h: #import <Cocoa/Cocoa.h> #import "CopyQueue.h"; @interface Copier : NSObject { IBOutlet NSTextField *statusField; IBOutlet NSTextField...

is it possible to use other controller page as a firstpage at navigation base template in objective c?

hi friend, i am new at the area of objective c. i am trying to build an iphone app by using navigation based template. as usually at the navigation based template show UITableView page at first but i would like to show other controller page at the starting of this app that UIView page. is it possible? ...

Is it possible to use UIPickerView in cocos2d?

hello, I am developing iPhone 2d game by using cocos2d. I need a Picker. Is it possible to use Picker in cocos2d ! If possible then tell me, How can I use a Picker in cocos2d ? ...

UIWebView and PDF files

I am loading a relatively small PDF file (140kb) using UIWebView and even though this is working fine, I'm finding it lags a lot when I scroll and zoom. The PDF is a map so there's quite a lot of text and lines on it so I'm wondering if there's any way to accelerate it somehow so everything moves smoother? Would converting to PNG work be...

How to use NSScanner?

Hi, I've just read Apple's docu of NSScanner. I'm trying to get the integer of that string: @"user logged (3 attempts)". I can't find any example, how to scan within parentheses. Any ideas? Here's the code: NSString *logString = @"user logged (3 attempts)"; NSScanner *aScanner = [NSScanner scannerWithString:logString]; [aScanner sca...

Why am I having trouble with a deep copy in Objective C?

I'm assuming my understanding of how to perform a deep copy isn't just there yet. The same with some sub-optimal memory handling that I'm performing down below. This code below probably depicts a shallow copy, and I believe that's where my problem might be. I have some cookie-cutter code for an example that looks like the following: NSA...

What describes objective-C and Cocoa Bindings best?

I have trouble understanding Cocoa Bindings. Can someone explain me what this is all about, in an way that is humanly perceivable? ...

How expensive is UITableView's reloadData?

I'm curious just how expensive in as far as resources go is UITableView's reloadData? I have an app which will make roughly 10 subsequent HTTP requests, and as it gets data / preps, it reloads the tableView. As the data set grows larger and larger, it's becoming very sluggish. I'm trying to figure out if it's because of the amount of tim...

Unrecognised selector yet debug can see it.

I have a class that contains a collection of objects. I am trying to create a method that will return the first member of the collection matching a supplied predicate. Here is the collection method: ... //predicate is a boolean method that accepts an object as its single parameter -(id<Notation>) getFirstChildMatching: (SEL) predicate ...

UIScrollView Touches Don't Seem to Work

I used the "View-based Application" template in Xcode for an iPhone project and went into the view controller XIB. I changed the view from a basic UIView to a UIScrollView, and now the method - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; never gets called. I have an NSLog statement in there. It gets called just fine w...

ignoring messages in objective C

I have some obj-c code, i plan to send unsupport messages in plugin. However i cant seem to ignore messages. I thought "-(id) forward: (SEL) selector: (marg_list) arglist;" would solve it but it hasnt. How do i have this app run entirely without getting a warning and a termination call? #import <stdio.h> #import <objc/Object.h> //-----...

What is the job of an Object I am binding to?

When I use Interface Builder > Inspector > Bindings to set up an binding for one of my view Items (i.e. an textfield), then I have to specify an object to which this view item will be bound to. So I am wondering now, what exactly is the job of this object I specify in "Bind to:"? I assume that Interface Builder automatically creates som...

What describes an "Outlet" best in objective-c / Cocoa?

Can someone explain in an humanly understandable way what an "Outlet" is? ...