objective-c

can i write in XML file in objective c application?

i want to write some data in XML file.I can read in XML file but how can i write this. please give me some intruction. ...

Is NSNumber overkill for an instance-level counter?

I'm new to Objective-C and Cocoa. I've read that NSInteger and NSNumber are preferred when working with simple integers because they're the "platform-safe" versions of the primitive numeric types (and in NSNumber's case, wrapped in an object). So, I need a counter in my class that gets incremented when an NSTimer fires. On an Apple fo...

NStimer slow when use CGContextClipToRect in iphone device

I am new to iphone development. I used NSTimer scheduledTimerWithTimeInterval 0.01 seconds for game loop. The game consists drawscreen function inwhich I use CGContextClipToRect to clip the large images for animation. But the speed 0.01 seconds is working in simulator only not in the iphone(device). How can i overcome this problem? I res...

Am I using NSTimer correctly in iPhone View-based app?

I'm working on a simple proof-of-concept for an iPhone app (and important bit of info, I'm pretty new to Mac OSX development all around). I created a view based app with a timer. I declared my NSTimer in the interface of my app's controller, used @property and @synthesize, and I initialize it in the controller's viewDidLoad method with...

willAnimateSecondHalfOfRotationFromInterfaceOrientation not called in root view controller

I have created the one rootviewcontroller , and then make that geosensitive by writing - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } In rootviewcontroller willAnimateSecondHalfOfRotationFromInterfaceOrientation method is called and images are resizing. I also have so...

How do I change the background color of a cocoa NSBrowser?

How do I change the background color of a cocoa NSBrowser from the default white? Do I need to override something else to do this? I've searched online and not found anything useful. ...

UIWebView resetting my form input values

I have a UIWebView that is typically browsing a J2EE application but I have a hardcoded check in shouldStartLoadWithRequest: to find the string "mobile_get_photo" in the URL and if present push a new view controller onto the navigation controller that allows a user to select an image via the photo library or the phone. The mobile_get_p...

How can I dim the view in an iPhone application?

I've seen a lot of iPhone apps that will dim the screen with an activity indicator when it's updating or downloading something to let the user know it's busy. I know how to do the activity indicator but how do I go about doing the dimming? Please post example code if you can. ...

NSURLConnection crashing under 10.5.7

I have a little app that downloads stock prices and was working perfectly (for years) until my recent upgrade to 10.5.7. After the upgrade, the program would crash on this call: NSString *currinfo = [NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://finance.yahoo.com/d/quotes.csv?s=%@&f=l1c1p...

Why do all the Checkbox's in my Outline View check when only one is clicked?

I am using a Outline view with two columns one a text field the other a check box field. Each column is binded to a NSTreeController. The problem I have is that when I click on a Checkbox I only want it to check that one check box but it checks all of them in the column. To help answer my Question this is the Bindings : http://snapplr.co...

Referencing a method in the current object

First time poster so please be gentle. How do you reference a method in the current object in Objective-C? Is there something like in Java, the this keyword? Here is some fake code to clarify: @implementation FooBard - (void) foo { i = 1 m = [this bar: i]; } - (int) bar: int j { k = j - 1; return (k); } @end In Java I ...

Horizontal scrolling not working in tabBar of three20 project??

I am using the three20 open source project by Joe Hewitt. have the following code in a UITableViewController: _tabBar1 = [[TTTabStrip alloc] initWithFrame:CGRectMake(0, 0, 320, 41)]; _tabBar1.tabItems = [NSArray arrayWithObjects: [[[TTTabItem alloc] initWithTitle:@"item1"] autorelease], [[[TTTabItem alloc] initWithTitle:@...

NSTextFieldCell Delegate?

I have a text field cell in a table view, from which I need to be made aware when it ends editing. I thought I would set my Controller class as the text field cell's delegate, and then use NSTextField's delegate method textDidEndEditing:, but realized that the text field cell doesn't seem to have delegate methods? Why is this, and what...

Locking details of synthesized atomic @properties in Obj-C 2.0

The documentation for properties in Obj-C 2.0 say that atomic properties use a lock internally, but it doesn't document the specifics of the lock. Does anybody know if this is a per-property lock, a per-object lock separate from the implicit one used by @synchronized(self), or the equivalent of @synchronized(self)? ...

Add to arrayController, edit Core Data attribute

EDIT What I'm not sure of is how to access an entity from the model in the code, and how to access a specific instance of an entity in that code. That sums up the main issues I'm having. END EDIT I have a tableview with a button to add to it. When the button is clicked, the user is presented with an open dialog where they select ...

Retrieve HTTPResponse/HTTPRequest status codes iPhone SDK?

I need to check and evaluate the HTTP Status Codes in my iPhone app. I've got an NSURLRequest object and an NSURLConnection that sucessfully (I think) connect to the site: // create the request NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"] cachePolicy:NSURLRe...

NSTextFieldCell Coordinates

I'm trying to get the NSPoint cooridnates of an NSTextFieldCell, but NSTextFieldCell doesn't inherit from NSView, and therefore doesn't have the frame method. Any ideas on how to get around this? I'm trying to use Matt Gemmel's MAAttachedWindow to attach little helper popups to certain elements. I want to attach it to an area on the wi...

Interesting Scope Problem, Explanation?

I just discovered a bug where the code looked something like this: char *foo = malloc(SOME_NUM * sizeof(char)); if (!processReturnsTrueOrFalse(foo)) { free(foo); char *foo = malloc(SOME_NUM * sizeof(char)); // More stuff, whatever } This compiles, but it's weird that I am allowed to define two variables within the same fun...

Objective-C instance variable pointers

Hello hello, I'm new to objective C and I just wanted to get a general clarification on when to use a pointer and when not to, when declaring instance variables. The example I can think of is UIView vs. a BOOL. UIView I would make a pointer, BOOL I would not (because the compiler yelled at me). Any general guidance would be awesome. ...

Why are Objective-C delegates usually given the property assign instead of retain?

Hi all, I'm surfing through the wonderful blog maintained by Scott Stevenson, and I'm trying to understand a fundamental Objective-C concept of assigning delegates the 'assign' property vs 'retain'. Note, the both are the same in a garbage collected environment. I'm mostly concerned with a non-GC based environment (eg: iPhone). Directl...