Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Unknown Behaviour by xcode

obaidjawadobaidjawad Posts: 133Registered Users
Below is my .m Class

In my class, I'm calling the action method that is -(IBAction)submitpost; so when I call it, it executes the code and jumps to refresh method to parse the XML. To my shockness I don't know the parsing is done sometimes and sometimes not. To check that I have debug by putting breakpoints on the methods of parse below, and when there is a time xcode executes all functions it executes all methods but when xcode doesn't then it only jumps to the refresh method from the -(ibaction)submitpost; method. But after refresh method is called none other methods are called. I don't why? Can anybody please help me out, as this function works sometime and sometimes not.

I have put the breakpoints on each method.
#import "writeblog.h"
#import <QuartzCore/QuartzCore.h>
#import "RSSEntry.h"
#import "ASIHTTPRequest.h"
#import "GDataXMLNode.h"
#import "GDataXMLElement-Extras.h"
#import "NSDate+InternetDateTime.h"
#import "NSArray+Extras.h"
#import "WebViewController.h"
#import "UniqueDomainIDBlog.h"


@implementation writeblog
@synthesize posttext;
@synthesize allEntries = _allEntries;
@synthesize feeds = _feeds;
@synthesize queue = _queue,webView;


- (void)refresh {

for (NSString *feed in _feeds) {
NSURL *url = [NSURL URLWithString:feed];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[_queue addOperation:request];
}

}

- (void)parseRss:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
NSString *status = [rootElement valueForChild:@"status"];

NSLog(@"the status is %@ ",status);

NSUserDefaults *st=[NSUserDefaults standardUserDefaults];
[st setObject:status forKey:@"statusdefault"];

if ([status intValue]==1) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Post Sent Successfully"
message:@""
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alertView show];
[alertView release];

}

if ([status intValue]==0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Post send failed"
message:@"Please try again"
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alertView show];
[alertView release];

}


}


- (void)parseFeed:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
if ([rootElement.name compare:@"rss"] == NSOrderedSame) {
[self parseRss:rootElement entries:entries];
}
else if ([rootElement.name compare:@"response"] == NSOrderedSame) {
[self parseRss:rootElement entries:entries];

}
else {
NSLog(@"Unsupported root element: %@", rootElement.name);
}
}


- (void)requestFinished:(ASIHTTPRequest *)request {

[_queue addOperationWithBlock:^{

NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:[request responseData]
options:0 error:&error];
if (doc == nil) {
NSLog(@"Failed to parse %@", request.url);
}
else {

NSMutableArray *entries = [NSMutableArray array];
[self parseFeed:doc.rootElement entries:entries];


}
}];

}

-(IBAction)hidekeyboard{
[posttext resignFirstResponder];

}

-(IBAction)submitpost{
NSString *text=posttext.text;
NSUserDefaults *st2=[NSUserDefaults standardUserDefaults];
NSString *session=[st2 objectForKey:@"session_iddefault"];

self.allEntries = [NSMutableArray array];
self.queue = [[NSOperationQueue alloc] init] ;

NSString *url1=[NSString stringWithFormat:@"http://sme.allomani.com/apps/api.php?action=blog_write&amp;domain_id=1&amp;content=%@&amp;session_id=%@&quot;,text,session];

self.feeds = [NSArray arrayWithObjects:url1,
nil];

NSLog(@"session %@ and url is %@",session,url1);

[self refresh];


- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];
posttext.layer.borderWidth = 5.0f;
posttext.layer.borderColor = [[UIColor grayColor] CGColor];
posttext.layer.cornerRadius = 5;
posttext.clipsToBounds = YES;
controlflowin=1;


// Do any additional setup after loading the view from its nib.
}



- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
Any help will be greatly appreciated, thank you.

Sign In or Register to comment.