AFRaptureXMLRequestOperation*operation=[AFRaptureXMLRequestOperationXMLParserRequestOperationWithRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:@"http://legalindexes.indoff.com/sitemap.xml"]]success:^(NSURLRequest*request,NSHTTPURLResponse*response,RXMLElement*XMLElement){// Do something with XMLElement }failure:^(NSURLRequest*request,NSHTTPURLResponse*response,NSError*error,RXMLElement*XMLElement){// Handle the error}];[operationstart];

If subclassing AFHTTPClient then we just need to use registerHTTPOperationClass to register it with AFRaptureXMLRequestOperation

I created this extension several months ago, but recently updated it to use ARC and included some
minor tweaks based on some official extensions.
Feel free to play around with it, fork it and send any pull requests.

It is always better to fade in image as they load, as this leads to great user experience. It is much better than just have the images abruptly appear. In order to achieve this we can make use of CATransition which is a subclass
of CAAnimation.

If you are fetching remote images, a great framework to use is SDWebImage. The following
sample code assumes you are using this framework.

12345678910111213

// We need this import as we'll be adding the animation to the UIView's layer#import <QuartzCore/QuartzCore.h>// Let's say we have UIImageView *imageView [imageViewsetImageWithURL:[NSURLURLWithString:@"http://example.com/example.png"]completed:^(UIImage*image,NSError*error,SDImageCacheTypecacheType){if(image){CATransition*transition=[CATransitionanimation];transition.type=kCATransitionFade;// there are other types but this is the nicesttransition.duration=0.34;// set the duration that you liketransition.timingFunction=[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];[imageView.layeraddAnimation:transitionforKey:nil];}}];

You can also customize the direction of the transition using the subtype property of the CATransition.

This is a quite nice feature if you have a UITableView displaying lots of images.

I wanted to do a custom format placeholder text in a UITextField and found out about the attributedPlaceholder property on the documentation.

Great! That should be easy.

1234567

NSDictionary*textAttributes=@{NSFontAttributeName:[UIFontitalicSystemFontOfSize:15.f]};NSAttributedString*attributedPlaceholder=[[NSAttributedStringalloc]initWithString:@"Placeholder"attributes:textAttributes];// Assume we already have created UITextField *textField[textFieldsetAttributedPlaceholder:attributedPlaceholder];

So I ran the build and the placeholder should be italic as I wanted, right? WRONG!

Apparently, this is a bug. And if you had read until this line, please go and file a bug report to Apple so they can fix this.

Now, there are some workarounds for this problem. The one I ended up using is to subclass UITextField and override drawPlaceholderInRect:

1234567

-(void)drawPlaceholderInRect:(CGRect)rect{// Set to any color of your preference[[UIColorlightGrayColor]setFill];// We use self.font.pointSize in order to match the input text's font size[self.placeholderdrawInRect:rectwithFont:[UIFontitalicSystemFontOfSize:self.font.pointSize]];}

It is possible to make this subclass more general and use NSAttributedString’sdrawInRect: if attributedPlaceholder is set. But for my requirements the above snippet was enough.

When it comes to XML parsing in iOS, developers usually first stumble upon NSXMLParser. NSXMLParser is a SAX Parser included on the iOS SDK. While it works fine, developers usually end up writing tons of lines to parse XML documents.

There are better and faster alternatives to work with. I personally enjoy working with RaptureXML. There are different factors when deciding which XML libary to choose. Often, the most common is speed.

Currently, there is no much data on speed tests. The usual source for this data is this dated (March 2010) excellent blog post. On it, the author checks various libraries and performs tests based on Apple’s source.

Since then, several of these libraries have been updated and some new libraries have become available as well. Not to say, that we have now multi-core devices such as the iPhone 5. Therefore, I updated the source code to include the latest versions of the XML libraries and included a few more.

Libraries tested

All the tests were performed on an iPhone 5, each of them ran 10 times. Here’s a chart with the results:

The fastest library was TBXML and most of the libraries finished within 0.01 seconds. It was a surprise that TinyXML2 came last, taking double the time of TinyXML.

From this tests one can conclude, that under modern hardware, the choice of speed does not matter that much as most of the libraries perform very similarly. The choice breaks down to a matter of preference, to which library you enjoy the most working with.

The code for this test can be found on my repo. Feel free to fork it and improve any of the tests, specially if they will help making the parsing faster.

In this particular example it will bring the camera. There are other options as well.

123456

// This will bring the CamerapickerController.sourceType=UIImagePickerControllerSourceTypeCamera;// Option for showing the photo librarypickerController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;// This will just show the photos / videos viewpickerController.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;

Note that the last two options require users to allow the app to access their photos / videos.

Don’t forget to check if the source type is available:

1234

if([UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){// Set sourceType to UIImagePickerControllerSourceTypeCamera// and present controller}

If you do not care about movies, just still images we can set the media typpe to kUTTypeImage.

123

#import <MobileCoreServices/MobileCoreServices.h>// Don't forget to add MobileCoreServices.framework to the projectpickerController.mediaTypes=@[(NSString*)kUTTypeImage];

This class also supports the ability to let users crop and scale pictures. This is very useful if want to get square pics, for instance to update a social profile picture.

-(void)imagePickerController:(UIImagePickerController*)pickerdidFinishPickingMediaWithInfo:(NSDictionary*)info{[selfdismissViewControllerAnimated:YEScompletion:NULL];// UIImagePickerControllerEditedImage is useful if you allowed// editing of imagesUIImage*image=[infoobjectForKey:UIImagePickerControllerEditedImage];if(image==nil)image=[infoobjectForKey:UIImagePickerControllerOriginalImage];// Do something with the image}

As you can see, UIImagePickerController is quite easy to implement and it has lots of options that you can make use of.
It also allows you to set a custom overlay and define your own camera buttons.