I am very new to programming and Objective-C and I am trying to work out what is wrong with my code. I have read a bit about blocks but I don\'t know how any of what I have read
Your block is retaining self
because you're using self
as the delegate of the UIAlertView. If self
is also retaining the block, they're retaining each other, which creates a retain cycle.
Try
__block WhateverTypeSelfIs *nonRetainedSelfForBlock = self;
[tweetViewController setCompletionHandler:
and
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:alertTitle
message:alertMessage
delegate:nonRetainedSelfForBlock
cancelButtonTitle:alertCancelButtonTitle
otherButtonTitles:otherAlertButtonTitle,nil];
Check the Apple docs, section Object and Block Variables. Objects referenced within a block are retained, unless you use __block.