NSUserDefaults for UIAlerview - ios

This is my code:
#import "RootViewController.h"
#implementation RootViewController
- (void)loadView {
self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
self.view.backgroundColor = [UIColor blackColor];
UIWebView *webView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
webView.scalesPageToFit = YES;
[self.view addSubview:webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://deathsrepo.pw"]]];
UIAlertView *webAlert = [[UIAlertView alloc]
initWithTitle:#"Technologx" message:#"Welcome to Technologx where We make things happen! If your new to the forum please create a account. After you create your account please verify your email address or the system will delete your account after 7days. Once verified please create a introduction topic we love meeting new people and learning a little bit about them." delegate:self cancelButtonTitle:#"Done" otherButtonTitles:#"OK", nil];
[webAlert show];
[webAlert release];
}
#end
How can I make my AlertView window only show up once. I want the user to be able to press 'OK' and it won't popup when they open the app again but if they just press "done" it will?

First, alert view is deprecated. Use an alert controller as shown below. Second, switch around where you are placing your code. I would recommend loading the web view in viewDidLoad:, but for the sake of simplicity let's stay with this.
- (void)viewDidAppear:(BOOL)animated {
self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
self.view.backgroundColor = [UIColor blackColor];
UIWebView *webView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
webView.scalesPageToFit = YES;
[self.view addSubview:webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://deathsrepo.pw"]]];
if([[NSUserDefaults standardUserDefaults] boolForKey:#"firstKey"]!=YES) {
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:#"Technologx"
message:#"Welcome to Technologx where We make things happen! If your new to the forum please create a account. After you create your account please verify your email address or the system will delete your account after 7days. Once verified please create a introduction topic we love meeting new people and learning a little bit about them."
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
}
UIAlertAction* ok = [UIAlertAction
actionWithTitle:#"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[[NSUserDefaults standardUserDefaults] setBOOL:YES forKey:#"firstKey"];
}];
[webAlert release];
}
#end
Let's talk about what we're doing. We check if user defaults key is nil, and if it is, show them the sheet. If they have ever clicked OK on the sheet, meaning they've seen it before, we setup a handler that will add any ol' thing to the key. Hence, the key is not nil ever again, so your sheet will never appear again once they've seen it.

#import "RootViewController.h"
NSInteger YourInt;
#interface RootViewController () <UIAlertViewDelegate>
#end
#implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
YourInt = [[NSUserDefaults standardUserDefaults] integerForKey:#"Saved"];
if (YourInt == 0) {
UIAlertView *Webalert = [[UIAlertView alloc] initWithTitle:#"Technologx" message:#"Welcome to Technologx where We make things happen! If your new to the forum please create a account. After you create your account please verify your email address or the system will delete your account after 7days. Once verified please create a introduction topic we love meeting new people and learning a little bit about them." delegate:self cancelButtonTitle:#"Done" otherButtonTitles:#"Ok", nil];
[Webalert show];
}
}
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
{
return YES;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) {
NSLog(#"Done");
} else if (buttonIndex == 1) {
NSLog(#"Ok");
YourInt = 1;
[[NSUserDefaults standardUserDefaults] setInteger:YourInt forKey:#"Saved"];
}
}
Hope it helps!

Related

Drawing a Rect on UIView

I'm trying to draw a rect on a UIView when a button is clicked, but for some reason isn't working...
- (IBAction)createNewGame:(id)sender {
[self dismissViewControllerAnimated:NO completion:nil];
//create the new game and add to the array of games, save the index of actual game.
FIALGameModel *newGame = [[FIALGameModel alloc] initWithRows:_row columns:_column];
[_games addObject:(newGame)];
_actualGame = [_games count]-1;
if(_debug==true) {
NSString* messageString = [NSString stringWithFormat: #"Creating a New Game with %d rows and %d columns.", _row, _column];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Alert"
message: messageString
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
}
UIView *test = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 60, 60)];
test.backgroundColor = [UIColor redColor];
[_areaGame addSubview:test];
}
The alert works fine, but the rect don't.
As #matt hints in comment, the most usual cause of this is that you've not bound your properties or fields to your UI components properly, or else you've tried to run this code before the UIView was loaded. In either case, _areaGame is nil and the addSubview call silently does nothing. Setting a breakpoint on the addSubview line and inspecting _areaGame is the quickest way to verify.

When UIButton is pressed and IBAction is called show UIAlertView with activity indicator in it until done

I have a very simple yet annoying question. I have two view controllers, in the first one i have a button that has to go to a server and do some work, i want to show an alert view containing a spinning indicator, that will show up as soon as the button is pressed and dismissed when the second view controller loads.
I tried this way :
- (IBAction)logMeInFunction:(id)sender {
UIAlertView *waitAlert = [[UIAlertView alloc] initWithTitle:#"Please Wait...." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
[waitAlert show];
/* Do Some Api testing and stuff */
[waitAlert dismissWithClickedButtonIndex:0 animated:YES];
[self performSegueWithIdentifier: #"logMe" sender: self];
}
Using this way, the alert show's up and dismisses instantly in the second view controller, not show's up in the first to inform the user that some work is being done and disappears in the second.
Any ideas?
The main problem with your code is that your server call needs to be asynchronous. You are now using dataWithContentsOfURL which is synchronous and which blocks your main thread.
An simple option would be to make that call in a other thread.
UIAlertView *waitAlert = [[UIAlertView alloc] initWithTitle:#"Please Wait...." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
[waitAlert show];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *strURL2 = [NSString stringWithFormat:#"MyURL"];
NSData *dataURL2 = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL2]];
NSString *strResult2 = [[NSString alloc] initWithData:dataURL2 encoding:NSUTF8StringEncoding];
NSDictionary *json2 = [strResult2 JSONValue];
NSMutableArray *userExists = [[NSMutableArray alloc] init];
dispatch_async(dispatch_get_main_queue(), ^{
[waitAlert dismissWithClickedButtonIndex:0 animated:YES];
[self performSegueWithIdentifier: #"logMe" sender: self];
});
});
Instead of showing UIAlertview, show the Custome UIView with the label and indicator...
try the below code...
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0.0,0.0,200.0,200.0)];
customView.layer.cornerRadius = 5.0;
customView.layer.borderColor = [UIColor lightGrayColor].CGColor;
customView.layer.borderWidth = 1.0;
[self.view addSubview:customView];
UILabel* loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(leftMargin, topMargin, 200.0, 100.0)];
[loadingLabel setNumberOfLines:4];
[loadingLabel setTextAlignment:NSTextAlignmentCenter];
[loadingLabel setText:#"Loading..."];
[customView addSubview:loadingLabel];
UIActivityIndicatorView* loadingIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(leftMargin + 75.0, topMargin + 45.0, 50.0, 50.0)];
[loadingIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[customView addSubview:loadingIndicator];
once the server work finished hide/remove the custom view and load your next view controller....
IMO, you need to utilize background thread. The main thread will run a HUD and the background thread will hit server and perform operation.
Psuedo Code:
-(void)sendRequestToServer
{
// TODO: Call server to do some function
// Once you are done with server action, you have to come back to MAIN THREAD
[self performSelectorOnMainThread:#selector(hideHUD) withObject:nil waitUntilDone:NO];
}
- (IBAction)logMeInFunction:(id)sender
{
[MBProgresssHUD showHUDAddedTo:self.view animated:YES];
[self performSelectorInBackground:#selector(sendRequestToServer) withObject:nil];
}
-(void)hideHUD
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
NOTE:
Please look at the examples given in the clink and also have a look at dispatch_async and dispatch_sync blocks.
Hope it helps!
To possibilities:
1) UIAlertView or any other view with animation will take some mili second time to present itself on screen. So it might be possible that your service call is quick here and gives you response back before even UIAlertView present on screen.
2) UIAlertView needs a time to display on screen, so might be possible that your server call makes UIAlertview wait until web service execution done as both are performing on main thread. So you should wither use delay to call service function after displaying alert view or you should use GCD.

Activity Indicator View not spinning

I have below code where I am loading some link in webview.
- (void)viewDidLoad
{
mySpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[self openWebPage:fileName];
[self.view addSubview:myWebView];
[self.view addSubview:mySpinner];
mySpinner.center = CGPointMake(self.view.frame.size.width / 2.0, 100);
}
-(void)openWebPage:(NSString*)address {
NSURL*url=[NSURL URLWithString:address];
NSURLRequest*request=[NSURLRequest requestWithURL:url];
myWebView.scalesPageToFit = NO;
[myWebView loadRequest:request];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
UIAlertView *errorView = [[UIAlertView alloc] initWithTitle:#"Error!!!" message:#"Please make sure you are connected to 3G or Wi-Fi." delegate:nil cancelButtonTitle:#"Dismiss" otherButtonTitles:nil, nil];
[errorView show];
mySpinner.hidden = YES;
[mySpinner stopAnimating];
}
-(void)webViewDidStartLoad:(UIWebView *)webView2 {
NSLog(#"webViewDidStartLoad");
mySpinner.hidden = NO;
[mySpinner startAnimating];
NSLog(#"step 1");
NSDate *future = [NSDate dateWithTimeIntervalSinceNow: 2 ];
[NSThread sleepUntilDate:future];
NSLog(#"step 2");
}
-(void)webViewDidFinishLoad:(UIWebView *)webView2 {
NSLog(#"webViewDidFinishLoad");
mySpinner.hidden = YES;
[mySpinner stopAnimating];
}
What I am doing is at webViewDidStartLoad I am displaying spinner and starting animating using [mySpinner startAnimating];, but it didn't spin. It just stays as it is (no spinning).
Any idea what is going wrong?
Edit 1
I have webview delegate #interface WebDetailsViewController : UIViewController<UIWebViewDelegate>
Also I have added [NSThread sleepUntilDate:future]; just to verify whether activity indicator view is animating or not.
Below is what I have from NSLog
2013-06-23 16:29:28.843 GulfLab[2048:907] webViewDidStartLoad
2013-06-23 16:29:28.845 GulfLab[2048:907] step 1
2013-06-23 16:29:30.847 GulfLab[2048:907] step 2
2013-06-23 16:29:31.836 GulfLab[2048:907] webViewDidFinishLoad
Edit 2
Well well well the problem is in below line...
[UIView beginAnimations: #"Showinfo"context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController: secondView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
Below is what I have...
One first view controller, I have buttons and when I click those button I am coming to second view controller and there I am displaying the web file based on button pressed.
My client wanted some effect while coming to second view and for that I added above code. But because of that, I am facing the activity problem.
Any idea what changes do I need to do?
On further investigation I found that problem is in this line...
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
but I need this line as else animation is not happening...
Also today I noticed that if I touch webview, then it starts animating
Grrr... someone help me
If somebody runs into a similar problem where there Indicator is not spinning:
Make sure the Animating property is set in your storyboard.
It's possible you aren't getting it to animate because you are not on the main UI thread. Try adding it to a dispatch queue on the main loop to force it on the main loop and it should animate.
dispatch_async(dispatch_get_main_queue(), ^{
[mySpinner startAnimating];
}];
Try to put this code after alloc init
mySpinner.hidesWhenStopped = false;
Delete mySpinner.hidden = YES/NO in your code;
Just add [mySpinner setHidesWhenStopped:YES]; in viewDidload
Then you just start and stop.
- (void)viewDidLoad
{
mySpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[mySpinner setHidesWhenStopped:YES];//set Hidden here
[self openWebPage:fileName];
[self.view addSubview:myWebView];
[self.view addSubview:mySpinner];
[self.view bringSubviewToFront:mySpinner]; //Add if still not show
}
I really think the [NSThread sleepUntilDate:future]; call is killing you in this situation. Most of my code is integration with a 3rd party piece of hardware that will block the main thread in certain scenarios and when that happens I'll have similar behaviors as yours where an element of the UI appears but is in a slightly frozen state until I either tap the screen to "jump start" the UI or the blocking call is completed.
If I were you I would start by getting rid of the sleepUntilDate call then remove the call to stop mySpinner to make sure it is in fact spinning so that when you run into a longer call of webViewDidFinishLoad you'll be assured it's working.
This is how I do a pop-up with a spinner in my code. Not exactly what you had asked but it is somewhat similar.
In your *.h file:
#interface v3ViewController : UIViewController
{
UIAlertView *megaAlert;
}
#property (nonatomic, retain) UIAlertView *megaAlert;
- (IBAction) invokeMegaAnnoyingPopup;
- (IBAction) dismissMegaAnnoyingPopup;
In your *.m file:
#synthesize megaAlert;
- (IBAction) dismissMegaAnnoyingPopup
{
[self.megaAlert dismissWithClickedButtonIndex:0 animated:YES];
self.megaAlert = nil;
}
- (IBAction) invokeMegaAnnoyingPopup
{
self.megaAlert = [[UIAlertView alloc] initWithTitle:#"Please wait..."
message:nil delegate:self cancelButtonTitle:nil
otherButtonTitles: nil];
[self.megaAlert show];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(130, 70);
[indicator startAnimating];
[self.megaAlert addSubview:indicator];
}

Alert view shifted upwards due to the addition of Text field in it

I am creating an Alert view on click of a button. I have placed a UITextfield in it. But the Alertview is shifted upwards in the screen. I am not able to bring it back at the center of the screen.
Here is my code and Screenshot.
and the code for creating this Alert view is this:-
- (IBAction)btn_cancelAppointment_click:(id)sender
{
// Here We are Creating Alertview which asks for
UIAlertView* cancelAlert = [[UIAlertView alloc] init];
[cancelAlert setDelegate:self];
[cancelAlert setTitle:#"Are you sure you want to request cancellation of this appointment?"];
[cancelAlert setMessage:#" "];
[cancelAlert addButtonWithTitle:#"NO"];
[cancelAlert addButtonWithTitle:#"YES"];
UITextField * txt_cancelNote = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 88.0, 245.0, 30.0)];
[txt_cancelNote setBackgroundColor:[UIColor whiteColor]];
[txt_cancelNote setBorderStyle:UITextBorderStyleRoundedRect];
[txt_cancelNote setPlaceholder:#"Enter cancellation note"];
txt_cancelNote.tag = 11;
[cancelAlert addSubview:txt_cancelNote];
cancelAlert.delegate = self;
[cancelAlert show];
}
So, if somebody can tell me how to bring it back to the center of the screen. Any help will be highly appreciated.
Give a try by setting the transform property of the UIAlertView
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:#"Test" message:nil delegate:self cancelButtonTitle:#"OK" otherButtonTitles: nil];
alertView.transform = CGAffineTransformMakeTranslation(x, y);

Obj-C: Issue with object from block

Im pretty new in programming and im currently looking at blocks which im having some issues with. Im having a hard time reaching an object which is defined within my block. Actually I cannot really explain this issue in an accurate way, so ill give you some code and pictures, and hope that it makes sense and that you excuse my dodgy knowledge and try to help me understand the problem.
So Im starting off by running this block
- (void)fetchSite
{
//Initiate the request...
[[FeedStore sharedStore] fetchSites:^(RSSChannel *objSite, NSError *err) {
//When the request completes, this block will be called
if (!err) {
//If everything went ok, grab the object
channelSite = objSite;
//Now we need to extract the first siteId and give it to sharedstore
RSSItem *site = [[channelSite sites] objectAtIndex:0];
NSString *currentSiteId = [NSString stringWithFormat:#"%#", [site siteNumber]];
NSLog(#"DEBUG: LVC: fetchSite: currentSiteId: %#", currentSiteId);
[[FeedStore sharedStore] setCurrentSiteId:currentSiteId];
//Now we can call fetchEntries
[self fetchEntries];
} else {
//If things went bad, show an alart view
UIAlertView *av = [[UIAlertView alloc] initWithTitle:#"Fel" message:#"Kunde inte bedömma din position relaterat till närmaste hållplats, försök gärna igen" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[av show];
//Stop UIRefreshControl
[refreshControl endRefreshing];
}
}];
}
Then fetchEntries is called:
- (void)fetchEntries
{
void (^completionBlock)(RSSChannel *obj, NSError *err) = ^(RSSChannel *obj, NSError *err) {
if (!err) {
//If everything went ok, grab the object, and reload the table and end refreshControl
channel = obj;
//Post notification to refreshTableView method which will reload tableViews data.
[[NSNotificationCenter defaultCenter] postNotificationName:#"RefreshTableView" object:nil];
//Stop UIRefreshControl
[refreshControl endRefreshing];
} else {
//If things went bad, show an alart view
UIAlertView *av = [[UIAlertView alloc] initWithTitle:#"Fel" message:#"Kunde inte hämta avgångar för din hållplats, försök gärna igen" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[av show];
//Stop UIRefreshControl
[refreshControl endRefreshing];
}
};
//Initiate the request...
if (fetchType == ListViewControllerFetchBus) {
[[FeedStore sharedStore] fetchDepartures:completionBlock];
selectedSegment = 0;
} else {
[[FeedStore sharedStore] fetchDeparturesMetro:completionBlock];
selectedSegment = 1;
}
}
Reloading the table:
- (void)refreshTableView:(NSNotification *)notif
{
[[self tableView] reloadData];
}
Heres where I populate my custom table cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//Get received data from fetchEntries block
RSSItem *item = [[channel items] objectAtIndex:[indexPath row]];
//Get the new or recycled cell
ItemCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ItemCell"];
//Set the apperance
[[cell lineNumberLabel] setTextColor:[UIColor whiteColor]];
[[cell lineNumberLabel] minimumScaleFactor];
[[cell lineNumberLabel] setFont:[UIFont boldSystemFontOfSize:22]];
[[cell lineNumberLabel] adjustsFontSizeToFitWidth];
[[cell lineNumberLabel] setTextAlignment:NSTextAlignmentCenter];
[[cell destinationLabel] setTextColor:[UIColor whiteColor]];
[[cell displayTimeLabel] setTextColor:[UIColor whiteColor]];
[[cell displayTimeLabel] setTextAlignment:NSTextAlignmentLeft];
//Configure the cell with the item
if ([item lineNumber]) [[cell lineNumberLabel] setText:[item lineNumber]];
if ([item destination]) [[cell destinationLabel] setText:[item destination]];
if ([item displayTime]) [[cell displayTimeLabel] setText:[item displayTime]];
if ([item displayRow1]) [[cell destinationLabel] setText:[item displayRow1]];
return cell;
}
So when im running through these blocks in normal state everything works like a charm.
But the issues starts when Im calling fetchSite method from an UIActionSheet, or actually from an UISegmentedControl which is a subview of UIActionSheet, this takes place here:
- (void)displayPickerView
{
//First im creating an instance to PickerViewController which will handle the UIPickerView which is a subview of UIActionSheet. pickerArrayFromChannel holds entries for UIPickerView to show in its ViewController.
pickerViewController = [[PickerViewController alloc] init];
[pickerViewController initWithItems: pickerArrayFromChannel];
pickerViewController.delegate = self;
//initiate UIActionSheet which needs no delegate or appearance more than its style
actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
//Create frame and initiate a UIPickerView with this. Set its delegate to the PickerViewController and set it to start at row 0
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.delegate = pickerViewController;
pickerView.dataSource = pickerViewController;
[pickerView selectRow:0 inComponent:0 animated:YES];
//Add this pickerView as subview to actionSheet
[actionSheet addSubview:pickerView];
//Now, create two buttons, closeButton and okButton. Which really are UISegmentedControls. Action to closeButton is (for now) dismissActionSheet which holds only following code " [actionSheet dismissWithClickedButtonIndex:0 animated:YES]; " and works fine
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Stäng"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:#selector(dismissActionSheet) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
//OK button
UISegmentedControl *okButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Visa avgångar"]];
okButton.momentary = YES;
okButton.frame = CGRectMake(10, 7.0f, 100.0f, 30.0f);
okButton.segmentedControlStyle = UISegmentedControlStyleBar;
okButton.tintColor = [UIColor blueColor];
[okButton addTarget:self action:#selector(updateDeparturesFromActionSheet) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:okButton];
//Now show actionSheet
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
}
Now lets look at updateDeparturesFromActionSheet method and we're getting close to where my issues begin (if your still reading, thank you for that
- (void)updateDeparturesFromActionSheet
{
//Dismiss the actionSheet
[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
//Send the selected entry from UIPickerView to currentAddress property in FeedStore, fetchSite method will eventually use this
[[FeedStore sharedStore] setCurrentAddress:[pickerViewController addressFromPickerView]];
//Call fetchSite method
[self fetchSite];
}
fetchSite then eventually calls fetchEntries method, which eventually populate my table. I store received obj (from block) in an property called channel
void (^completionBlock)(RSSChannel *obj, NSError *err) = ^(RSSChannel *obj, NSError *err) {
if (!err) {
//If everything went ok, grab the object, and reload the table and end refreshControl
channel = obj;
The channel object looks like this
channel RSSChannel * 0x07464340
NSObject NSObject
currentString NSMutableString * 0x00000000
lvc ListViewController * 0x08c455d0
items NSMutableArray * 0x08c452d0
sites NSMutableArray * 0x08c452f0
parentParserDelegate id 0x00000000
pickerViewArray NSMutableArray * 0x08c45320
As you can see when I populate my tables cells, I use the info from items inside of the channel object.
Now if your still with me (and havnt fallen asleep) so far I will explain my actual problem, now when you have (hopefully) all the relevant code.
So when I press okButton in my UIActionSheet, updateDeparturesFromActionSheet method gets called. Which calls fetchSite which eventually calls fetchEntries and so far so good, these blocks performs and I get back information. But when I grab fetchEntries obj and put it in channel, it doesnt seems to "update" this object with the new information grabbed by the blocks obj object. Among others it does not seems that channel object gets a new place in the memory (it keeps 0x07464340).
My first thought was to make sure channel object gets released by ARC, by removing all owners of that object, but it seems that even if I do so (and then doublecheck that its null with simple NSLog(#"%#") it keeps getting its old values and memory reference back when I trigger the "update".
After many attempts to release the channel object and doing all sorts of stuff (creating new arrays (outside of block) amongst other things). I keep thinking that some special rule within blocks that I dont understand is messing with me. Any ideas?
Please let me know if anything isnt clear because I've expressed myself bad, its hard to explain an issue that you dont understand yourself. Thanks in advanced.

Resources