Tag: cocoa touch

+ — what's the point?

As NSString strings are immutable, what is the value of the stringWithString: class method? I get the utility when used with NSMutableString, I just didn’t see the utility with the NSString class.

Class method equivalent of -respondsToSelector:

Is there a class method equivalent to -respondsToSelector:? Something like +respondsToSelector:? The reason I am asking is because by implementing -respondsToSelector: on a class level, I get a compiler warning: “found ‘-respondsToSelector:’ instead of ‘+respondsToSelector:’ in protocol(s)”. The code looks like this: Class <SomeProtocol> someClass = [someInstance class]; if ([someClass respondsToSelector:@selector(someSelector:)]) { someVar = [someClass […]

How to find out the modulus and exponent of RSA Public Key on iPhone/Objective C

Is there a possible way to find out the modulus and exponent of the Public Key, created with SecKeyGeneratePair (the Security Framework in general)?

How does -performSelector:withObject:afterDelay: work?

I am currently working under the assumption that -performSelector:withObject:afterDelay: does not utilize threading, but schedules an event to fire at a later date on the current thread. Is this correct? More, specifically: – (void) methodCalledByButtonClick { for (id obj in array) { [self doSomethingWithObj:obj]; } } static BOOL isBad = NO; – (void) doSomethingWithObj:(id)obj { […]

How to get substring of NSString?

If I want to get a value from the NSString @”value:hello World:value”, what should I use? The return value I want is @”hello World”.

How to detect a pause in input for UISearchBar/UITextField?

I have the following UISearchbar code: – (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; NSString* endpoint =[NSString stringWithFormat:@”http://www.someurl/”, [searchText stringByReplacingOccurrencesOfString:@” ” withString:@”+”]]; NSURL* url = [NSURL URLWithString:endpoint]; NSURLRequest* request = [NSURLRequest requestWithURL:url]; GTMHTTPFetcher* myFetcher = [GTMHTTPFetcher fetcherWithRequest:request]; [myFetcher beginFetchWithDelegate:self didFinishSelector:@selector(searchResultsFetcher:finishedWithData:error:)]; } I want to send this request after a pause in input and […]

drawRect not being called in my subclass of UIImageView

I have subclassed UIImageView and tried to override drawRect so I could draw on top of the image using Quartz 2D. I know this is a dumb newbie question, but I’m not seeing what I did wrong. Here’s the interface: #import <UIKit/UIKit.h> @interface UIImageViewCustom : UIImageView { } – (void)drawRect:(CGRect)rect; @end And the implementation: #import […]

How to constrain autorotation to a single orientation for some views, while allowing all orientations on others?

This question is about iOS device rotation and multiple controlled views in a UINavigationController. Some views should be constrained to portrait orientation, and some should autorotate freely. If you try and create the simplest setup with three views, you’ll notice that the autorotation behavior has a few very nasty quirks. The scenario is, however, very […]

Check iOS version at runtime?

This is sort of a follow on from my last question. I am using beginAnimations:context: to setup an animation block to animate some UITextLabels. However I noticed in the docs that is says: “Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods instead.” My question is […]

Reading samples via AVAssetReader

How do you read samples via AVAssetReader? I’ve found examples of duplicating or mixing using AVAssetReader, but those loops are always controlled by the AVAssetWriter loop. Is it possible just to create an AVAssetReader and read through it, getting each sample? Thanks.