KVO crash NSKVODeallocate

This crash happens when an instance gets released before all key value observers pointing to its properties release. You need to call removeObserver:forKeyPath: before releasing the instance.

In another scenario, it will crash if you call removeObserver:forKeyPath: on an instance if none of the key value observers are pointing to its properties.

how to uninstall unnecessary simulators in Xcode?

You can find and delete the simulators from the path /Library/Developer/CoreSimulator/Profiles/Runtimes. Restart Xcode in order to take effect.


You can delete a simulator from Xcode by navigation through Menu > Window > Devices > Simulators.

Convert iPad xib to iPhone version

We can go with the following approach to get iPhone version of iPad xibs already exist in the project. With this approach we no need to create a new xib and manually add all the subviews.

1. Xcode recognises the iPhone version of a XIB if the suffix is ~iphone (lowercase only) and iPad version if its ~ipad. If no suffix exists then it will consider it as an iPhone version. Lets suffix all the existing xib names with ~ipad.

2. Duplicate all the xib files and open them in TextEditor and do the following.

change “com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB” to “com.apple.InterfaceBuilder3.CocoaTouch.XIB”
change “iOS.CocoaTouch.iPad” to “iOS.CocoaTouch”
change iPad size (width=”1024″ height=“768”) to iPhone size (width=“320″ height=“568″)

3. Add the xib to the project and open it on Xcode.

4. Select the root view and go to the attributes inspector.

5. Change the orientation to portrait and size to Retina 4-inch Full Screen.

6. Adjust the frame of all the subviews.

Make vertical scrollbar always visible in UIScrollView

Download : https://github.com/jaredsinclair/JTSScrollIndicator


Add the following statements in the method initWithScrollView:

  • [_scrollView setShowsHorizontalScrollIndicator:NO];
  • [_scrollView setShowsVerticalScrollIndicator:NO];

Comment all the statements in the method hide:


Added the following method declarations

  • – (void)show:(BOOL)animated;
  • + (BOOL)indicatorShouldBeVisibleForScrollView:(UIScrollView *)scrollView;


#import “JTSScrollIndicator.h”
@property (strong, nonatomic) JTSScrollIndicator *indicator;


- (void)viewDidLoad {
[super viewDidLoad];
self.indicator = [[JTSScrollIndicator alloc] initWithScrollView:scrollview];
self.indicator.backgroundColor = [UIColor colorWithRed:5.0/255.0 green:127.0/255.0 blue:231.0/255.0 alpha:1.0];

- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
scrollview.contentOffset = CGPointMake(0.0, 1.0);
[self.indicator show:YES];

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self.indicator scrollViewDidScroll:scrollView];

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
[self.indicator scrollViewDidEndDragging:scrollView willDecelerate:decelerate];

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self.indicator scrollViewDidEndDecelerating:scrollView];

- (void)scrollViewWillScrollToTop:(UIScrollView *)scrollView {
[self.indicator scrollViewWillScrollToTop:scrollView];

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
[self.indicator scrollViewDidScrollToTop:scrollView];

Objective-C – How to use member variables in the categories.


@interface UIView (ObjectTagAdditions)
@property (nonatomic, retain) id objectTag;


#import <objc/runtime.h>
static char const * const ObjectTagKey = "ObjectTag";

@implementation UIView (ObjectTagAdditions)
@dynamic objectTag;

- (id)objectTag {
    return objc_getAssociatedObject(self, &ObjectTagKey);

- (void)setObjectTag:(id)newObjectTag {
    objc_setAssociatedObject(self, &ObjectTagKey, newObjectTag, OBJC_ASSOCIATION_RETAIN_NONATOMIC);

Cited from : http://oleb.net/blog/2011/05/faking-ivars-in-objc-categories-with-associative-references/