objective-c

UITableViewController numberOfRowsInSection doesn't affect the actual number of rows!

Hello everyone. I'm a beginner, so please excuse me if I'm missing something obvious :-) The title says it all. The table I'm having problem with is pushed from another table controller, and there is only one section in this table, and I'm using custom cells. Here is the code for numberOfRowsInSection: - (NSInteger)tableView:(UITableVi...

What is clipRect in NSTableView?

Hello, I am trying to understand the meaning of clipRect in a table view embedded inside a scroll view. I assumed that the clip rect is the visible portion of the table view. This means that the width of the rect should not change as long as the table view is not resized, but upon monitoring the width of the clip rect in the following c...

Getting iPhone mainBundle Files

I dont know the exact code i need to retrieve all of the filenames of the resources in my iphone apps mainBundle. if i could have some kind of code like: NSArray *array = [[NSBundle mainBundle] getAllResourceFilenames]; it would be helpful. thanks inadvanced for any help! ...

What is the difference between an instance variable/method and a class variable/method in Objective-C?

I've seen many other questions on this same topic but they're not very clear to me, someone new to Objective-C. I need a plain english explanation. 'Coder speak' is much too difficult for me to understand at this point in my learning. ...

Use NSString in different file.

Hello All: I have two files(file1.m and file2.m) and two strings(NSString *str1 = [[NSString alloc] initWithString:@"hello!"] in file1.m and NSString *str2 in file2.m).I set str2 = str1 by a method and then the str2's value is "hello!". Then I change the str2 to "hello hello!" in file2.m,and i want the str1 in file1.m is also chang...

Getting Notifications of isDocumentEdited

Hello, is it possible to bind/get notifications of the isDocumentEdited property of NSDocument without calling the will/didChangeValueForKey: methods on every change? ...

How to change font color of individual characters in a UIPickerView row?

I have an app which shows text in a UIPickerView based on a search. I want to highlight specific letters in the string that are there as a result of a wildcard character. For example, if I searched for "CA?", one of the rows will show "CAT" and I want only the letter "T" to be in the color blue. Any ideas? The user gets immediate fee...

Objective C delegate - why specify an instance in the first part of function definition?

I'm confused as to what the first part of the following function declaration means. It adds an object instance as part of the function definition. E.g. In some sample code, class ItemsViewController which derives from UITableViewController has this function definition: -(void) tableView:(UITableView*) aTableView didSelectRowAtIndexPath...

iPhone Objective C - Saving Data

I have a NSMutableArray of some instances of a custom class (it has a NSString, CGPoint, and a UILabel). I need to save this array. I tried using writeToFile:Atomically: but that doesn't work with custom classes (I think). Is there any other simple way to save that? And how would i load it? Thanks everybody in advance:) Any ideas, sugg...

how to compare 2 string variables

please tell me how to compare 2 string variables i am not talking about a string variable and a string(that is already give in this site i tried it if (s isEqualToString: str) { // ... } here s ans ss are two NSMutableStrings already having values .... but this doesnot work i also tried isEqual but failed again please help remem...

Porting Python code to run on iphone

Hi! Does anyone have any experience in porting Python code to either C++ or Objective-C? If so, can you give me some advice on docs or tutorials which my help me? The Python code I'm hoping to port is mostly non-gui and involves a lot of string manipulation, regex, and extensions of container datastructures. Speed is less important. Bas...

How to get the width of an NSString?

I am trying to get the width of an NSString (ex. NSString *myString = @"hello"). Is there a way to do this? Thanks. ...

how to globally initialize a button in objective C?

I am using two buttons. I want to access these two buttons object from two different function.- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization button1= [UIButton buttonWithType:UIButton...

Objective-C, how can i hook up a method in another class

Objective-C keeps all its methods in a huge hashtable - so shouldn't it possible to patch this table and replace an existing method with my own patched method (which then calls the original)? I need a way to hook up the NSWindow KeyUp method in a window which i can't subclass cause it's already created. I need some code or at least so...

how can i use webview object in cocoa to display webpage?

i want to display the web page in my program ,i use the WebView object in my IB (.xib) but it dosent work ,is there any sampel code ,not doc or article? view_w.h @interface view_w : NSObject { IBOutlet WebView* Web; } -(IBAction) google:(id) sender; @end view_w.m -(IBAction) google:(id) sender { NS...

Possible with a backgroundapp that compares current pos with predfined pos?

Just a hypothetical question. I am thinking of making an app that read the current GPS position and compares it to several predfined positions. That is not hard but what I need to do is have it run in the background and if the device gets within a certain range of the predfined position it should make the user aware of that prefinded po...

Core Data Navigation with Relationship.

My Core Data model looks like this: The players relationship of the entity Game is a to many relationship and will hold all the player objects related to that Game entity. I have a UITableView that looks like this <-- link . The Table View displays all the games, how would I, when selecting a Game show/push another UITableView to dis...

UIScrollView still receives scroll events underneath a UIButton

I have a full-screen UIButton to capture all touch events, so that the scrollView underneath doesn't scroll. However, for some reason, it's not working. Can someone tell me a way to create a view that will capture tap and swipe events so this won't happen? Thanks! ...

Better way to convert an NSArray of NSStrings to NSNumbers

Hi, Consider the following code NSString *param_string @"1:3:6:10:15:22:28:30"; NSArray *params = [param_string componentsSeparatedByString:@":"]; NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterNoStyle]; NSMutableArray *convertedArray = [[NSMutableArray alloc] initWithCapac...

How does one run multiple threads in objective c?

I have some code which runs in a timer, but I would like to have a few of these run simultaneously. How are threads run in objective c? Can I put the current code in a method, and just start up threads and called the method in each thread? ...