objective-c

'SomeViewController' may not respond to '-alloc'

I'm currently setting up this view to be swapped with another in an iPhone game. When I use this code... - (void)viewDidLoad { menuViewController = [[menuViewController alloc] initWithNibName:@"SomeViewController" bundle:nil]; self.menuViewController = menuViewController; [self.view insertSubview:menuViewController.view a...

Remove Done Button From Number Pad upon a New Keyboard Loading

Alright, I'll try to explain this the best I can. I have an iPhone app and it has a text field which the user can only input Numbers. Not a problem there. However, there is no done button on the numpad, so I can't make it disappear. I could make a button that the user presses to dismiss the keyboard, but I'd rather have a done button...

How to refer each UIButton

I add 10 buttons to UIScrollView for (int i=0; i<10; i++) { UIButton *btn = .... [ScrollView addSubview:btn]; } How can i refer to each button ? ...

How to search address book with a phone number?

Hi All, I just want to search my IPhone's address book by a received call's phone number. How can I proceed further in this case? Suppose my received call is in the format of (ISD code) xxxxxxxxxx, like (+1 1234567890) or (001 1234567890) or (+11234567890) or (+1 (123) 456-7890) or (1234567890 without ISD code) or something else. So how...

How to implement - (void)complete:(id)sender?

Hi! I am trying to override NSTextView - (void)complete:(id)sender method but I can't find any example on how to do it. What does this method do? There are examples, or where I can find the original implementation? Thank you! —Alberto ...

Why not refresh my objective-c object after receive a message?

A have an NSView object, and it get an message after i push in the Menü bar the Open submenü. It load exchange data from a textfile, and it should render it in a CustomView. So the -(IBAction)loadExchangeData:(id)sender load the data, and store in a NSMutableArray*, and after it should rendered it by drawRect. But! In the drawRect ...

Change UIWebView's color while loading content

I have a UIWebView in my app that shows some html-formatted text (loaded from a .plist file from my bundle). The UIWebView takes about 1 second to render the text on the screen and during that second the whole UIWebView is white. I have tried setting the backgronud color of the view to clear or black but that did not do anything. I also ...

xcode macros objective c not working

In xcode if I type in if then hit escape it gives me an option to autocomplete to an if block macro. I just saw that there is a list of objective c macros like this for example a is supposed to be alloc init call. However when I type in a then hit escape it says no completions found. What am I doing wrong here? ...

CoreData & TimeMachine

Hi, I'm developing a CoreData non-document-based app. The SQLite store size is regularly of order ~60MB, and it's cumbersome that Time Machine backs up the entire database once per hour. Is there a way to make Time Machine back up only the changes? I'm thinking of abusing the CoreData external records API for spotlight and let the mach...

What does "-(void)" mean in this function declaration? `-(void)awakeFromNib`

How come whenever i have to use awakeFromNib protocol, i have to put it in this format? -(void)awakeFromNib What is the need for -(void)? Thanks, FlaminLardMan (p.s. im a noob at xcode and objective-c) ...

Create a UIBarButtonItem with a title, and an image, and the default background

I am trying to create a UIBarButtonItem that looks like the normal Apple ones, but I'd like to include an image and a piece of text. As far as I can tell, you can't specify both an image and a title (the image shows but the title doesn't if you set both). Also, if you use a customView, then you lose the BarButtonItem look and feel. Wh...

Breaking NSString into lines (to fit desired width)

I'm trying to get a NSString broken into lines to fit a desired width (as it would happen inside sizeWithFont:constrainedToSize:). Is there a better way to do this than guessing where the breaks would happen in sizeWithFont? ...

Ideas for toy projects with which to familiarize oneself with Cocoa and Cocoa Touch

[Distilled from this question, with less informality.] What are some things a new Cocoa programmer should write as sample projects, outside of the hand-holding of a tutorial? Let's have one project idea per answer. If you have multiple ideas to suggest, post multiple answers. It'll help for you to also list what Cocoa concepts your pr...

How to launch an app in debug mode from xcode with a URL

Is there a way for xcode to launch an application with an app URL? I've read the answer to this question http://stackoverflow.com/questions/1239000/debugging-app-when-launched-by-push-notification, and it works great for single tests. I'm trying to write unit tests for launching the app with lots of different URLs, and using the previo...

Parse NSURL path and query (iphoneOS)

Are there any standard objects or functions to parse an NSURL's components? Clearly I could write one, but why re-invent the wheel? [NSURL path] will return an NSString like "argX=x&argY=y&argZ=z" What I would rather get back is a dictionary populated with {@"argX" => @"x", @"argY" => @"y", @"argZ" = @"z"} For the path, which returns ...

Extract part of a NSString in Cocoa in an efficient way

Hi, How could I extract a part of an NSString before certain word(s): For example: If the keyword set of 'separators' is an NSArray of the following words "Series" and "documentary" and if the NSStrings where "Chain two Series documents" <---- I'd like to extract "Chain two" "Chain documentary documents" <---- I'd like to extract ...

Track all Objective-C's alloc/allocWithZone/dealloc

Sorry for long description, however the questions aren't so easy... My project written without GC. Recently I found a memory leak that I can't find. I did use new Xcode Analyzer without a result. I did read my code line by line and verified all alloc/release/copy/autorelease/mutableCopy/retain and pools... - still nothing. Preamble: St...

Fast way to convert array of points into triangle strip?

I have an array of CGPoints (basic struct with two floats: x and y). I want to use OpenGL ES to draw a textured curve using these points. I can do this fine with just two points, but it gets harder when I need to make a line from several points. Currently I draw a line horizontally, calculate its angle from the points given, and then ro...

Should I define overloaded inherited method in the header file in ObjC?

Hi, well the question is the one I put in the title: "Should I define overloaded inherited method in the header file in ObjC?" Thanks UPDATE: I was wondering this because I will make my project's documentation using Doxygen, and maybe is better to declare overloaded inherited method because of the documentation. For example for method ...

Objective-C methods which their only parameter is an NSError object reference, How should I name them?

Hi, I was designing a class and I realize that I've got several methods that the only parameter they have is the output parameter for errors. The problem is how should I name this methods, because they can get very confusing. I've been reading the Apple's Code Guidelines and it saids nothing about this. Here is an example: -(BOOL)loginE...