Tag: cocoa touch

Getting a list of files in a directory with a glob

For some crazy reason I can’t find a way to get a list of files with a glob for a given directory. I’m currently stuck with something along the lines of: NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; NSArray *dirContents = [[NSFileManager defaultManager] directoryContentsAtPath:bundleRoot]; ..and then stripping out the stuff I don’t want, which sucks. But […]

UIButton inside a view that has a UITapGestureRecognizer

I have view with a UITapGestureRecognizer. So when I tap on the view another view appears above this view. This new view has three buttons. When I now press on one of these buttons I don’t get the buttons action, I only get the tap gesture action. So I’m not able to use these buttons […]

How can I get a precise time, for example in milliseconds in Objective-C?

Is there an easy way to get a time very precisely? I need to calculate some delays between method calls. More specifically, I want to calculate the speed of scrolling in an UIScrollView.

Check that a input to UITextField is numeric only

How do I validate the string input to a UITextField? I want to check that the string is numeric, including decimal points.

Managing multiple asynchronous NSURLConnection connections

I have a ton of repeating code in my class that looks like the following: NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; The problem with asynchronous requests is when you have various requests going off, and you have a delegate assigned to treat them all as one entity, a lot of branching and ugly code […]

Why do you use an underscore for an instance variable, but not its corresponding property?

Possible Duplicate: How does an underscore in front of a variable in a cocoa objective-c class work? I am new to iphone development.I am doing research on voice recording in iphone .I have downloaded the “speak here” sample program from Apple.It consist of LevelMeter.h file, in which @interface LevelMeter : UIView { CGFloat _level, _peakLevel; […]

When do you make an underscore in front of an instance variable?

Possible Duplicate: How does an underscore in front of a variable in a cocoa objective-c class work? I’ve seen this at Apple, inside UIPickerView.h: id<UIPickerViewDataSource> _dataSource; why’s that underscore there? Does it have a special meaning? A Convention I must know about?

Deep copying an NSArray

Is there any built-in function that allows me to deep copy an NSMutableArray? I looked around, some people say [aMutableArray copyWithZone:nil] works as deep copy. But I tried and it seems to be a shallow copy. Right now I am manually doing the copy with a for loop: //deep copy a 9*9 mutable array to […]

How to use custom delegates in Objective-C

I need to know about the usage of delegate methods in Objective-C. Can anyone point me to the correct source?

Convert HTML to NSAttributedString in iOS

I am using a instance of UIWebView to process some text and color it correctly, it gives the result as HTML but rather than displaying it in the UIWebView I want to display it using Core Text with a NSAttributedString. I am able to create and draw the NSAttributedString but I am unsure how I […]