objective-c

Is there a way to use - (UIView *)viewWithTag:(NSInteger)tag with a custom UIView

I have a class that inherits from UIView However when trying to use the follow (UIView *)viewWithTag:(NSInteger)tag I get the warning: *incompatible Objective-C types initializing 'struct UIView *', expected 'struct CustomView ' Right now I have made a custom method that returns my custom view, the method uses a for loop with view.subv...

Memory Management Autorelease vs. Alloc Question

3 correlated questions: 1.Do the code snippets below provide the very same results in terms of memory? NSBundle *bundle=[[NSBundle alloc] init]; [bundle release]; bundle=nil; and NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; NSBundle *bundle=[NSBundle mainBundle]; [pool drain]; pool=nil; bundle=nil; 2.Why in NSBundle...

Number of Objects in Autorelease Pool

Is there any way to query the number of objects that reside in a given NSAutoreleasePool? This is really important for me, because in my game there are several loops and I need to know how effectively I'm autoreleasing my autoreleased objects. ...

NSAutoreleasePool question

I drained an autorelease pool. The warning *** attempt to pop an unknown autorelease pool means the autorelease pool was created and drained in different methods - that's fine. But does it mean such pool is NOT being drained? Is there a solution? ...

Does this Objective-C code leak memory?

One thing I'm concerned about is I create two ints, but don't release them. Would it be better to make them NSIntegers? -(void) flipCoin { int heads = [headsLabel.text intValue]; int tails = [tailsLabel.text intValue]; if (random() %2 ==1 ) { heads++; } else { tails++; } headsLabel.text...

problems with creating an NSWindow

Hi, I am new to Cocoa, and I am just experimenting with creating a window programmatically (without using Interface Builder). I start a new Cocoa Application in Xcode, then I remove the window from the nib file in Interface Builder to replace it with my own one. In the main function, I add the code: NSWindow* myWindow; myWindow ...

Resizing an NSView smaller than its subviews?

Couldn't find anything on the net about this; and wondered if anyone on SO has a solution. I have an NSView with several subviews that are centered by removing the left and right anchor points. When I resize my view, programatically or with the mouse, to a smaller width than the subviews: it pushes them off center. Has anyone come acros...

iPhone Sdk: How to add a second UINavigationController??

Hi, i created an app from the navigation-based template given by apple. Now i want to add a second navigation controller to my application including a new UITableView. Can anybody show my how to do this? Thanks! ...

Presenting modal view controller from popover

Hi, I have a view controller that is inside a popover, and I want to present a modal view controller from it. Here's my code: EditDateViewController *dateViewController = [[EditDateViewController alloc] initWithNibName:@"EditDateViewController" bundle:[NSBundle mainBundle]]; UINavigationController *navController = [[UINavigationCon...

iPhone updating view

Hello, I am trying to solve a problem considering update of an view. First I switch to another view by using: - (void)viewSettings { settingsViewController = [[SettingsViewController alloc] initWithNibName:nil bundle:nil]; [[self viewController] presentModalViewController:settingsViewController animated:YES];} Which is a delegate Me...

how to request url to connect

how to request url to execute or connect to server .. what i was using not working.. NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@%@%@%@%@%@%@%@%@",[ConfigDB valueForKey:@"mailURL"], @"?ownerID=", [ConfigDB ownerID], @"&userid=",[ConfigDB userID],@"&pID=",pid,@"&emailAddress=",emailTxtField.text,[ConfigDB valueForK...

Reloading only one UITableViewCell on a UITableview

Ok Guys, here's the situation I have. I'm using a UITableViewController with Core Data. The table has about 200 cells, that basically function as a checklist. When you tap a cell, that cell has a checkbox that gets toggled set to the UITableViewCell.imageView ( the UIImageView assigned to the left of the label). Anytime I use either ...

NSString initWithData returns null

I am pulling data from a website via NSURLConnection and stashing the received data away in an instance of NSMutableData. In the connectionDidFinishLoading delegate method the data is convert into a string with a call to NSString's appropriate method: NSString *result = [[NSString alloc] initWithData:data ...

Autorelease Drowning

I came across a problem that seems to be called "drowning" in autorelease pools. My code creates and destroys objects correctly. However, I use some class methods that autorelease several variables without my knowing about it. Considering they loop thousands and thousands of times every minute... I find myself drowning in thousands of u...

What should I use to control input devices and more

Hi, I am fluent in C++, Java, and Python and can pretty much pick up any other skill given enough time (no surprise there, I'm sure 99.9% of the people reading this share the same ability). I have an idea for a small app for Mac OS X and I was wondering what technology I should employ/learn to get it working. I need some minimal OS X ...

Post HTTP data error

NSString *myRequestString = [NSString stringWithFormat:@"&nbr=%@&import=%@",tmpString,noSpaces]; NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString UTF8String ] length: [ myRequestString length ] ]; NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString: @"http://mysite.com/c...

UITableView and NSOperation Logic Problem

Hello everyone, My project is a Thumbnail image gallery. I implemented it using a UITableView which has custom cells. In each cell there's 4 UIButtons which has the images. And the images are downloaded from the internet using their URLs. The way I'm assigning the images to the buttons is using Jasarien's method described in this post....

Using NSPopUpButtonCell with NSTableView

Hello I am trying to use a NSPopUpButtonCell inside an NSTableView. Basically when you select an item in the pop up I want it displayed in the table view column/row. When an item in the popup cell is pressed I store it inside the data source using "tableView:setObject:forTableColumn:row", then when the table requests data I retrieve and ...

textView: How to remove text when editing begins and not when firstRsponder...

The headline says it all. In my textEditView I have an textView with a lightgrey default text in it, "Context". The textView is the firstresponder. What I want to do is to remove the text when the editing begins, not when the textView becomes firstResponder. Hmmm a idea is forming in my head... could I run a check of the NSRange someho...

Key Value Coding Primitives

I have some automatic de-serialization code that will set an object's properties using KVC. I need to add de-serialization support for primitives (int, double, float), but I am unable (or unsure of how) to use "setValue: forKey:" with primitives. The property lookups must be performed at runtime. Any ideas? Thanks. ...