objective-c

What's the purpose of unsigned type here?

Sorry for the multitude of iPhone Programming newb questions but.. what is the reason for having an unsigned type for something such as - (unsigned)count for the NSArray class. Why not just define it as - (int)count ? ...

multi-touch touchesBegan

I'm having a bit of a problem trying to get touchesBegan to respond to multi touch. -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; for (UITouch *touch in allTouches) { CGPoint location = [touch locationInView:touch.view]; if(CGRectContainsPoint(snare.frame, location) && l...

Weird behavior when creating an NSDate of January the 1st and the 2nd

Hello, I'm creating a date like this : NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"YYYY"]; NSInteger year = [[dateFormatter stringFromDate:[NSDate date]] intValue]; NSLog(@"NSInteger YEAR : %...

Gradual memory leak in loop over contents of QTMovie

I have a simple foundation tool that exports every frame of a movie as a .tiff file. Here is the relevant code: NSString* movieLoc = [NSString stringWithCString:argv[1]]; QTMovie *sourceMovie = [QTMovie movieWithFile:movieLoc error:nil]; int i=0; while (QTTimeCompare([sourceMovie currentTime], [sourceMovie duration]) != NSOrderedSame) ...

use of CLLocationManager class in iPad?

Hi Frnz, Can we use CLLocationManager class to determine the position of the user in an iPad app or is it used only for iPhones? ...

iphone float vs integer rounding?

Okay, from what I understand, an integer that is a fraction will be rounded one way or the other so that if a formula comes up with say 5/6 - it will automatically round it to 1. I have a calculation: xyz = ((1300 - [abc intValue])/6) + 100; xyz is defined as an NSInteger, abc is an NSString that is chosen via a UIPicker. I want the...

How to replace an object in an NSMutableArray at a given index with a new object

Hi guys. I have an NSMutableArray object(retained, synthesized as all) that is initiated just fine and I can easily add objects to it using the 'addObject:' method. But if I want to replace an object at a certain index with a new one in that NSMutableArray, it doesn't work. For example: ClassA.h @interface ClassA : NSObject { NSM...

[NSCFArray row]: unrecognized selector sent to instance 0x3953a20

I get a crash with this console message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFArray row]: unrecognized selector sent to instance 0x3953a20' This happens when I scroll trough a table that gets its data from an array of dictionaries. ...

iPhone Twitter Integration: Validating login.

Update: Using the following gets back an XML response. Used NSXMLParser to check for "errors" element. Not the cleanest method but gets the job done. I am open for suggestions. NSURLResponse *response; NSError *error; NSData* result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString ...

Cocoa Bindings in the face of a million of items in an NSArray

I'm writing a GUI for MongoDB using Cocoa. It's going well, but I don't know how to make KVO properties that would be lazily loaded. How does one handle that? For instance, viewing the documents in a Mongo collection. The collection might have a million items in it. I suspect I shouldn't be downloading the full 2-5 GiB of data to my Coc...

How to use CFNetwork to get byte array from sockets?

Hi, I'm working in a project for the iPad, it is a small program and I need it to communicate with another software that runs on windows and act like a server; so the application that I'm creating for the iPad will be the client. I'm using CFNetwork to do sockets communication, this is the way I'm establishing the connection: char ip[...

Running and managing NSTimer in different NSThread/NSRunLoop

I'm writing a Cocoa application, with a GUI designed in Interface Builder. I need to schedule background activity (at regular intervals) without blocking the UI, so I run it in a separate thread, like this: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [self performSelectorInBackground:@selector(schedule) w...

XCode: insertSubview, removeFromSuperview, viewDidLoad... Pulling it all together.

I feel like I'm missing something basic here, and I would appreciate it if you'd help me pull it all together. Let's say that I have two view controllers... ViewAController and ViewBController. If I wanted to show viewA, I would do this: ViewAController *new_view = [[ViewAController alloc] initWithNibName:@"ViewAController" bundle:nil...

UIDatePicker, setting maximum and minimum dates based on todays date

If I have a UIDatePicker, and I wish to set the minimum and maximum date range to be between thirty years ago and thirty years in the future, how would I set that up? ...

How to iterate over an dictionary without knowing the keys, while getting key and object?

I have an NSDictionary and want to iterate over the objects. But at the same time, I need to know the key of the dictionary. I remember there was a special, fancy form of fast enumeration, but have forgotten the exact syntax. Anyone? ...

iPhone app crashes with sqlite3_bind_text()

I'm attempting to make a simple app that stores and displays flash cards, however I'm having an awful time getting my SQLite to work. The database connection is fine, but when I try an insert, it crashes and gives no indication of what went wrong. This is the code I am using to insert the flash card into the table. const char *insert =...

iPad allow other applications to import documents to my application

I'm building an iPad app that allows users to save files in it and I want users to be able to open and import documents from other applications to my application. For example, I know that if you received an email and you want to save the attachment to my application, you're able to click on it and "Open with..." and choose the applicatio...

How would one use Cocos2d to create a game like this.

http://itunes.apple.com/us/app/angry-birds/id343200656?mt=8&ign-mpt=uo%3D6 So I am getting started with this all game dev thing on iphone and I decided that I will start playing with Cocos2d as my starting engine. Now just so i have a goal in mind, I picked angry birds as my initial target of what sort of game play would I like to...

is <CLLocationManagerDelegate> necessary to get the users location?

the file that I need the users information in already has a -flipsideViewControllerDelegate-, so Is there a way that I can get the users location coordinates without using the CLLocationManagerDelegate thing? ...

Subclassing an NSTextField

Given all the complex things I seem to cover every day, this appears to be a "what the heck am I doing wrong that seems to simple?" scenario! I would like to subclass an NSTextField to change the background color and text color. For simplicity sake (and to help anyone who hasn't ever subclassed anything before), here is the example of m...