objective-c

String class internals - caching character offset to byte relationship if using UTF-8

When writing a custom string class that stores UTF-8 internally (to save memory) rather than UTF-16 from scratch is it feasible to some extent cache the relationship between byte offset and character offset to increase performance when applications use the class with random access? Does Perl do this kind of caching of character offset t...

Push-Notification Badge auto increment.

I've been implementing the push service to my application, and I've been thinking about the application's badge. My app is a mail app (sorta) and I want to notify the user via push for new messages added to the inbox, I want the badge = number of new messages in the inbox. I thought of doing it server sided (provider) checking for new m...

iPhone Email app launch url

The url to launch email and start a new email on an iphone is "mailto://[email protected]". I just want to launch the email app, dropping the user at the main menu, or inbox. "mailto:" starts composing a new blank email I've tried "mail:", "email:" and a few others. Is there no way to just launch the email app? ...

How to debug Core Data crash on fetch request

Hi guys, the second time I execute [[MOC executeFetchRequest:request error:&error] lastObject]; after having said NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NSEntityDescription entityForName:@"Login" inManagedObjectContext:MOC]]; NSError *error = nil; it crashes with a EXC_BAD_ACCESS. Included is...

Objective-C: [sectionInfo name] of NSFetchedResultsSectionInfo needs to be dateFormatted

Hi guys, I have the following code: -(NSString *)tableView:(UITableView *)table titleForHeaderInSection:(NSInteger)section { id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections] objectAtIndex:section]; NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDat...

Howto use UITextField's drawTextInRect: method

Hi, I have a UITextField with a custom background, but now i want to change the text's position, so i have to use drawTextInRect:, but i can't figure out how to use it. The documentation says: You should not call this method directly. If you want to customize the drawing behavior for the text, you can override this method to do your dr...

Multiple images per row in UITableView's cell

Is there any sample code that would illustrate how to have multiple images within each row? Typical apps show a thumbnail to the left side with text to the right. I'd like to do that plus an image to the right of the text. How would I go about doing this? ...

iPhone Obj-C Properties

Hi, I'm a beginner following a book for creating iPhone apps. One of the steps was writing "UISwitch *whichSwitch = whichSwitch.isOn;" and I was just curious as to where "isOn" came from? In the documentation: on A Boolean value that determines the off/on state of the switch. @property(nonatomic, getter=isOn) BOOL on What does that...

What is kShowSegmentIndex?

-(IBAction)toggleShowHide: (id)sender { UISegmentedControl *segmentControl = (UISegmentedControl *)sender; NSInteger segment = segmentedControl.selectedSegmentIndex; if(segment==kShowSegmentIndex) [switchView setHidden:NO]; else [switchView setHidden:YES]; } ...

Function with argument to a NSInvocation method

Hi, I have a controller view who is using thoses 2 functions: [appDelegate getFichesInfo:[[self.fichesCategory idModuleFiche] intValue] ]; //first function self.fiche = (Fiche *)[appDelegate.fichesInfo objectAtIndex:0]; [appDelegate getFichesVisuels:[[self.fiche idFiche] intValue] ]; //second function not working self.fiche = (Fich...

Advantage and disadvantages of #defines vs. constants?

Can someone point out the advantages and disadvantages of using #defines vs. constants? Most of my work is done in C and Objective-C. Thanks! Matt ...

Objective-C: Unicode Date Format

Hi guys, I am trying to work out how to have the UNICODE representation of Sun, 03 May 2009 19:58:58 -0700 as eee, dd MMM yyyy HH:mm:s ZZZZ or something. I cant seem to get this working precisely ...

what is equivalent to Java packages in iPhone OS?

hello, I want to know which is the equivalent concept of Java packages in iPhone. Is it bundling or Static library? ...

Simplest way to implement twitter capability to iphone app

I need to add basic twitter support to an iphone app Does anyone know if there is a 3rd party solution like the facebook connect for twitter? OR if anyone knew if any of the popular Twitter iPhone apps (eg tweetie2 etc) have a custom URL scheme implemented so that it is possible to use their client to send a tweet from my app without ...

How to implement an accordion view for an iPhone SDK app?

Has anyone seen an implementation of an "accordion" (maybe called "animated outline") view for the iPhone? I found an example project for Cocoa, but before trying a port, I was hoping that someone has invented the wheel already. To make it clear, in a UIView, consider a stack of sections, each containing a header, and then some contents...

Objective-C: 'GameLayer' may not respond to '-addChild:z'

I am new to Objective-C and iPhone development in general. I am using the Cocos2d-iphone library for a game engine in an attempt to develop a very simple game. I have been following a few tutorials to get the hang of things and am attempting to put together a very simple "level" where some balls bounce around the screen using the Chipmu...

Objective-C: UITableView cells get written over each time when scrolling up and down

Hi guys, I have a UITableView that gets populated via CoreData, and have just noticed something strange. I have about 20 rows or so in the UITable, and when I scroll down the table and back up again, the cell's label gets written over the top of existing text, and keeps on doing it each time i go down and up again. My code for the CellF...

Match Parenthetical Expression With Regular Expressions

Hi, I am working on a math expression parser using regular expressions and I am trying to add support for parentheses. My parser works like this: function parse_expression(expression){ Find parenthetical expressions Loop through parenthetical expressions, call parse_expression() on all of them Replace parenthetical express...

Closing the main window in cocoa?

HI, How can i close a main window programatically in cocoa? I want to close my main window in a timer function(nstimer) when a boolean value is set? How can i do that, i dont want to terminate my application, But would like to just close my window. ...

Use of extern in Objective C

How good is it to use extern in Objective C? It does make coding for some parts easy.. but doesn't it spoil the object orientation? ...