Tag: objective c

How can I dynamically create a selector at runtime with Objective-C?

I know how to create a SEL at compile time using @selector(MyMethodName:) but what I want to do is create a selector dynamically from an NSString. Is this even possible? What I can do: SEL selector = @selector(doWork:); [myobj respondsToSelector:selector]; What I want to do: (pseudo code, this obviously doesn’t work) SEL selector = selectorFromString(@”doWork”); […]

C/C++/Objective-C text recognition library

Does anyone know of any free/open-source text recognition libraries in C/C++/Objective-C? Basically something that can scan an image, and read out all of the plain text.

UICollectionView: How to define a UICollectionViewLayout that supports horizontally and vertically scrolling?

At the moment I’m trying to create an UICollectionView, that should display a simple excel-like-spreadsheet, with rows and columns. This should be an easy task with UICollectionViews, I believed. And I really would like to do the implementation in UICollectionView, not in any grid framework. But at the moment I’m hanging a little bit. What […]

How to customize UIActionSheet? iOS

Is it possible to create an ActionSheet that have a label between two buttons like this image? Really need this right now. Can anyone help me? Thanks.

Getting the HTML source code of a loaded UIWebView

This question already has an answer here: Reading HTML content from a UIWebView 9 answers

Can I have a UIBarButtonItem with a colored image?

I have an image that I want to display on a UIBarButtonItem, but for some reason it only shows the outline of it and the rest is all white. How can I have it actually display the image? Thanks!

How to add hours to an NSDate?

I have a date converted to double value and saved in database. Now, I want to compare if currentDate > myDataBaseDate + 8 hours i.e., I want to get 8 hours added to myDataBaseDate. I’m converting date into double values. So how do I get 8 hours later time from my database saved date. How […]

OCUnit test for protocols/callbacks/delegate in Objective-C

Using OCUnit, is there a way to test delegate protocols? I’m trying this, which doesn’t work. -(void) testSomeObjDelegate { SomeObj obj = [[SomeObj alloc] initWithDelegate:self]; [obj executeMethod]; } -(void) someObjDelegateMethod { //test something here } I’m going to try calling the obj method on a different thread and have the test sleep until the delegate […]

mouseExited isn't called when mouse leaves trackingArea while scrolling

Why mouseExited/mouseEntered isn’t called when mouse exits from NStrackingArea by scrolling or doing animation? I create code like this: Mouse entered and exited: -(void)mouseEntered:(NSEvent *)theEvent { NSLog(@”Mouse entered”); } -(void)mouseExited:(NSEvent *)theEvent { NSLog(@”Mouse exited”); } Tracking area: -(void)updateTrackingAreas { if(trackingArea != nil) { [self removeTrackingArea:trackingArea]; [trackingArea release]; } int opts = (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways); trackingArea […]

How to use NSString drawInRect to center text?

How can I draw a NSString centered within a NSRect? I’ve started off with: (an extract from the drawRect method of my custom view) NSString* theString = … [theString drawInRect:theRect withAttributes:0]; [theString release]; Now I’m assuming I need to set up some attributes. I’ve had a look through Apple’s Cocoa documentation, but it’s a bit […]