objective-c

Use a UIPanGestureRecognizer to rotate view

Is it possible to rotate a view using a UIPanGestureRecognizer? I would like similar functionality to the rotation gesture but with only one finger. Thanks. ...

In Core Data, how do I access a specific attribute of every managed object (instance) of a given entity?

This is the Core Data object model I am working with (I am a new user, so I can't post pictures directly): http://i965.photobucket.com/albums/ae134/spindler77/Screenshot2010-07-26at112231AM.png All I am trying to do right now is to populate a UITableView with the "className" of every myClass instance the user has created and saved. My...

NSString: changing a filename but not the extension.

Times like this and my Objective-C noobness shows. :-/ So, the more I work on a routine to do this, the more complex it's becoming, and I'm wondering if there isn't just a simple method to change the name of a filename in a path. Basically, I want to change @"/some/path/abc.txt to @"/some/path/xyz.txt -- replacing the filename portion b...

Invalid operands to binary

Hi, I have a method to check weather a number is even or odd: -(BOOL)numberIsEven:(unsigned int *)x { if (x & 1) { return TRUE; } else { return FALSE; } } however whenever I compile it I get the error: Invalid operands to binary % So it's compiling into assembly as a modulus function and failing, somehow, however if...

NSNotification, not receiving callback

Can't figure out why I'm not getting my callback - any advice? -(void) playMovieWithURL:(NSURL *)url { [currentVC.view removeFromSuperview]; MPMoviePlayerViewController *movieControl = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; //register for playback finished call [[NSNotificationCenter defaultCent...

Memory Warnings cause app to crash

Everytime I get a memory warning, my app crashes. In the debugger, it crashes on the line where i try to set self.navigationItem.rightBarButtonItem = myButton; I implemented didReceiveMemoryWarning: and didn't include [super didReceiveMemoryWarning]. However it still crashes. Why is my view reloading? ...

How should I initialize an array that's a member of a UITableViewController?

The data source for my table view is a plain NSMutableArray that will be populated as the app runs, but will be empty when the Table View first loads. The class interface looks like this... @interface ViewController_iPhone : UITableViewController { NSMutableArray *serverList; } @property (retain, readonly) NSMutableArray *serve...

Convert NSDate to NSString

I have the following: NSDateFormatter* df = [[NSDateFormatter alloc]init]; [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; NSDate* date = [df dateFromString:[sDate stringByReplacingOccurrencesOfString:@"Z" withString:@"-0000"]]; [df release]; I would like the output string to be "9/20/10" How can I do this? ...

digits after decimal point

how to get digits after decimal point from float number in objective c ...

How can I append text to the bottom of my MFMailComposeViewController?

I would like to add the text "Sent from " to the bottom of the message if([MFMailComposeViewController canSendMail]){ MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; [controller setSubject:[NSString stringWithFormat:@"A message from: %@",se...

drag and Drop from application to Finder

is there a sample of code that can guide me to perform drag and drop from my cocoa application to the Finder ? I know that NSFilesPromisePboardType and relative stuff should be used, but so far I can only dnd from Finder to application and locally onto the application. Any help? thanks ! ...

Joining a NSArray of objects into a string, but need to be abke to specify property

I have a NSArray of Foo objects. @interface Foo : NSObject { } - (NSString *) name; @end I want to be able to join all these [Foo name] results into one NSString. In C# I would get a array of these by using LINQ, creating a Array of it, and feeding it to String.Join(): List<Foo> foo = [..]; String.Join(",", foo.select(F => ...

How do I add the UIApplicationDelegate to the end of the UIResponder chain?

I'm trying to provide an IBAction method for common functionality that is required at various parts of the app. i.e. Login is implemented modally, and if it succeeds results in a notification that allows all loaded view controllers to react to this event (transition from anonymous to authenticated) @interface MyAppDelegate : NSObject <...

OCUnit Error Codes

Does anyone know how to find a list of all the possible error codes thrown by the ostest utility, and their meanings? I noticed this to be a common problem for people, where they ask about an OCUnit failure with some code 138 or 139 that is completely opaque to them, and somebody who has encountered that particular error number points ou...

How can I present a UIView from the bottom of the screen like a UIActionSheet?

I'd like a UIView to slide up from the bottom of the screen (and stay mid-screen) like a UIActionSheet. How can I accomplish this? UPDATE: I am using the following code: TestView* test = [[TestView alloc] initWithNibName:@"TestView" bundle:nil]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.4]; [UIView setAni...

IKImageView hangs?

I'm writing a scanning application that is getting images from a document scanner, turning them into NSImages and then displaying them in an IKImageView. About half of the time, however, when I try to call setImage:ImageProperties in IKImageView, it just hangs. It only happens when I'm getting the image directly from the scanner, as I'...

getRandomColor but avoid dark colors: Help my algorithm

I am trying to get a random color. I have done it using brute force but this method seems overly laborious (though the distribution is pretty even): - (UIColor *) getRandomColor { // GOAL: reject colors that are too dark float total = 3; float one = arc4random() % 256 / 256.0; total -= one; float two = arc4random() % 256 / 256.0; ...

Can I use a category to override a method which is itself in category on the superclass?

@interface MySuperclass : NSObject { } @end @interface MySuperclass (MyCategory) - (void)myMethod; @end @interface MySubclass : MySuperclass { } @end @interface MySubclass (MyOtherCategory) - (void)myMethod; @end Is it defined which implementation of -myMethod will be called? Kochan states in Programming in Objective-C that...

Objective-C preprocessor available?

Does anyone know if the source code for Objective-C is still available from when it was just a pre-processor? Would be curious to see how it was implemented back then. Thanks. ...

compile problem for xcode 3.2

Hey I have problem compiling code in xcode 3.2 I have a code where it's using iOS 4's API, "MFMessageComposeViewController" It would compile fine with 4.0 under xcode, but when when i try to compile with 3.2 I get error because of "MFMessageComposeViewController". It seems that xcode can't find keyword for MFMessageComposeViewController....