objective-c

What will it take to add Objective-C support to the .NET common language runtime?

Is it possible for the .NET CLR to support Objective-C? Are there any reasons (either from a legal or implementational) standpoint why this wouldn't be possible? In the spirit of cross-platform application development, it would be nice to be able to write and run Objective-c applications on Windows machines. At least i think it would. ...

How do I trap OCUnit test pass/failure messages/events.

I'm trying to use xcodebuild and OCUnit with my Continuous Integration server (TeamCity). JetBrains offers test observer implementations for boost::test and CppUnit that format test output in a way that TeamCity can interpret. I need to do something similar for OCUnit if I want to use it. There appears to be a SenTestObserver class ...

Slicing up a UIImage on iPhone

Objective: take a UIImage, crop out a square in the middle, change size of square to 320x320 pixels, slice up the image into 16 80x80 images, save the 16 images in an array. Here's my code: CGImageRef originalImage, resizedImage, finalImage, tmp; float imgWidth, imgHeight, diff; UIImage *squareImage, *playImage; NSMutableArray *tileImg...

Timer and animation events trumping TouchesEnded events

Hi all, I've implemented a tap-and-hold handler using an NSTimer that I first set in the TouchesBegan overload. However, what I actually want is for an action to be continuously performed in quick-fire succession while the touch is being held. So, on timer expiry I call a handler to do the work, which then sets another timer and the cy...

Create a cross platform Windows, Mac OS X application

Hello, I would like to build an application that runs on both Windows and Mac OS X. I would also like it to leverage the best of what the platform it runs on has to offer with regards to Frameworks, API's etc. Is there a way to do this without having to write Objective-C code and then C# code? I've been thinking of C++ as an alternative ...

Does adding many many subviews to a viewcontrollers default view make my app slow?

I have an app where I create many uiviews and add them to the self.view of the UIViewController. My app is running really slowly. I am releasing all of my objects and have no memory leaks (I ran the performance tool). Can anyone tell me what could be making my app so slow? (code is below) [EDIT] The array has around 30 items. [/EndEdit]...

What's the difference between #import and @class, and when should I use one over the other?

I've been teaching myself Objective-C over the past month or so (I'm a Java head) and I've got my brain wrapped around most of it now. One thing that's confusing me at the moment: What's the difference between importing a class via @class vs doing a #import? Is one better than another one, or do I need to use one instead of the other i...

Layer Backed Views and Flickering Controls

I have a window which contains an NSBox control. In that NSBox are several other controls, (popups, text fields, etc...) I have two other NSBox's in the same NIB file that are filled with controls that I would like to swap out with the first under certain conditions. I would like this to happen with a nice cross fade effect, so I do the...

Best practices for overriding isEqual: and hash

How do you properly override isEqual: in Objective-C? The "catch" seems to be that if two objects are equal (as determined by the isEqual: method), they must have the same hash value. The Introspection section of the Cocoa Fundamentals Guide does have an example on how to override isEqual:, copied as follows, for a class named MyWidget...

UITableView issue when using separate delegate/dataSource

General Description: To start with what works, I have a UITableView which has been placed onto an Xcode-generated view using Interface Builder. The view's File Owner is set to an Xcode-generated subclass of UIViewController. To this subclass I have added working implementations of numberOfSectionsInTableView: tableView:numberOfRowsInS...

Why is my iPhone app crashing?

When I try to allocate a Texture2D the app just crashes. I've stepped through the code where the crash occurs... all I can tell is "EXC BAD ACCESS". Here is the line in the app delegate that makes it crash: _textures[myTex] = [[Texture2D alloc] initWithImage: [UIImage imageNamed:@"sometex.png"]]; sometex.png has been added to the re...

How do I make my iPhone app find my images?

My app crashes when I do the following in the applicationDidFinishLaunching event in the app delegate: _textures[mytex] = [[Texture2D alloc] initWithImage: [UIImage imageNamed:@"a.png"]]; However when I replace @"a.png" with @"/Users/MyUserName/Desktop/MyProjectFolder/a.png" everything works fine. I've experimented with the relati...

App crash when trying to access a subclass method after the object was initialized ( init ) using the parent initializer

Hi, I have a class that subclasses NSMutableArray. I init it using: MyClass class = [MyClass arrayWithContentsOfFile:path]; When i try to access any of my subclass methods the app crashes with this error: -[NSCFArray loadCards]: unrecognized selector sent to instance 0x454a30 * Terminating app due to uncaught exception 'NSI...

NSString indexOf in Objective-C

Are there anything similar to an indexOf function in the NSString objects? ...

SRV record lookup with iPhone SDK

In either a Windows or Mac OS X terminal if you type... nslookup -type=SRV _xmpp-server._tcp.gmail.com ... (for example) you will receive a bunch of SRV records relating to different google chat servers.. Does anyone have any experience in this area and possibly know how to service this information (hostname, port, weight, priority) ...

Unable to set text field on UILabel

I have created UITableCellView class called NoteCell. The header defines the following: #import <UIKit/UIKit.h> #import "Note.h" @interface NoteCell : UITableViewCell { Note *note; UILabel *noteTextLabel; } @property (nonatomic, retain) UILabel *noteTextLabel; - (Note *)note; - (void)setNote:(Note *)newNote; @end In the...

NSString tokenize in Objective-C

What is the best way to tokenize/split a NSString in Objective-C? ...

Escape sequences in STAssertEqualStrings

I'm writing a discovery test against the Cocoa API as I ramp up on all things Mac related. I'm currently trying to discover the best method for URL encoding a string. Using the Google toolbox for Mac I have a unit test that I intentionally cause a failure in: NSString* expected = @"ab%%20c"; NSString* encoded = @"ab c"; STAssertEqual...

Create NSString by repeating another string a given number of times

This should be easy, but I'm having a hard time finding the easiest solution. I need an NSString that is equal to another string concatenated with itself a given number of times. For a better explanation, consider the following python example: >> original = "abc" "abc" >> times = 2 2 >> result = original * times "abcabc" Any hints? ...

NSDateFormatter won't parse dates using locale settings?

I'm trying to parse dates using the user's date preferences [NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4]; NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateStyle:NSDateFormatterShortStyle]; NSDate *date = [ dateFormatter dateFromString:@"7/4/2008" ]; NSLog(@...