Tag Archives: code snippet

How-to: finding and replacing strings within a string in Objective-C

07 August

A few weeks ago someone posted a pretty interesting question on SO and I decided to have a crack to see how far I could get. In a nutshell, the OP was looking for an efficient way of finding and replacing URLs in an NSString, and possible use the same method to filter out rude […]

Comments Off on How-to: finding and replacing strings within a string in Objective-C Continue Reading →

Code snippet: how to get a screenshot of a UIView

10 February

Here’s something that could be useful if you’re trying to find a simple way of passing any UIView (and its subviews) as a UIImage – literally taking a screenshot of whatever is on that view: Found and slightly adapted from here [objc] + (UIImage *)captureView:(UIView *)view withArea:(CGRect)screenRect { UIGraphicsBeginImageContext(screenRect.size); CGContextRef ctx = UIGraphicsGetCurrentContext(); [[UIColor blackColor] […]