UIImage * imageSetting= [UIImage imageNamed:@"setting-button"];
UIImageView * imageView = [[UIImageView alloc]initWithImage:imageSetting];
self.editSettings = [[UIBarButtonItem alloc]initWithCustomView:imageView];
PO(self.editSettings);
In Addition:
self.editSettings = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonItemStylePlain target:nil action:nil];
PO(self.editSettings);
In both cases self.editSettings return null.
So, PO(self.editSettings) return null
You don’t show this in the question but this behaviour could be explained by
editSettingsbeing a weak property. If you assign directly to a weak property from an initialisation, ARC will remove the object since nothing has a strong pointer to it.Either use a local variable to create the bar button item, then make sure you add it to a toolbar or navigation bar before it goes out of scope, or change the property to strong.