Search Results

Search found 1559 results on 63 pages for 'nslog'.

Page 5/63 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • MFMailComposeViewController hangs my app

    - by Neal L
    Hi, I am trying to add email functionality to my app. I can get the MFMailComposeViewController to display correctly and pre-populate its subject and body, but for some reason when the user clicks on the "Cancel" or "Send" buttons in the nav bar the app just hangs. I inserted a NSLog() statement into the first line of mailComposeController"didFinishWithResult:error and it doesn't even print that line out to the console. Does anybody have an idea what would cause the MFMailComposeViewController to hang like that? Here is my code from the header: #import "ManagedObjectEditor.h" #import <MessageUI/MessageUI.h> @interface MyManagedObjectEditor : ManagedObjectEditor <MFMailComposeViewControllerDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate> { } - (IBAction)emailObject; @end from the implementation file: if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init]; mailComposer.delegate = self; [mailComposer setSubject:NSLocalizedString(@"An email from me", @"An email from me")]; [mailComposer setMessageBody:emailString isHTML:YES]; [self presentModalViewController:mailComposer animated:YES]; [mailComposer release]; } [error release]; [emailString release]; and here is the code from the callback: #pragma mark - #pragma mark Mail Compose Delegate Methods - (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { NSLog(@"in didFinishWithResult:"); switch (result) { case MFMailComposeResultCancelled: NSLog(@"cancelled"); break; case MFMailComposeResultSaved: NSLog(@"saved"); break; case MFMailComposeResultSent: NSLog(@"sent"); break; case MFMailComposeResultFailed: { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error sending email!",@"Error sending email!") message:[error localizedDescription] delegate:nil cancelButtonTitle:NSLocalizedString(@"Bummer",@"Bummer") otherButtonTitles:nil]; [alert show]; [alert release]; break; } default: break; } [self dismissModalViewControllerAnimated:YES]; } Thanks!

    Read the article

  • NSURLConnection not "firing" until UITableView scrolls..

    - by Simon
    Hi, I've got a UITableView that loads an image asynchronously and places it in the UITableViewCell once it's loaded (I'm using almost the exact same code as in the "LazyTableImages" tutorial). This works fine for all images when I scroll the table, but it's not loading the images that are first in the view. The code is definitely working fine as the class that actually sends the NSURLConnection request is being called correctly (I added an NSLog and it reached the console). The NSURLConnection is just not calling the delegate methods (didReceiveData, connectionDidFinishLoading, etc). Here's my code: HomeController.m - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; NSArray *feed = [feeds objectAtIndex: indexPath.row]; /** * Name of person */ [...] /** * Feed entry */ [...] /** * Misc work */ [...] } FeedRecord *feedRecord = [self.entries objectAtIndex:indexPath.row]; if( !feedRecord.image ) { if (self.table.dragging == NO && self.table.decelerating == NO) { [self startIconDownload:feedRecord forIndexPath:indexPath]; } cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"]; } return cell; } - (void)startIconDownload:(FeedRecord *)feedRecord forIndexPath:(NSIndexPath *)indexPath { IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath]; if (iconDownloader == nil) { iconDownloader = [[IconDownloader alloc] init]; iconDownloader.feedRecord = feedRecord; iconDownloader.indexPathInTableView = indexPath; iconDownloader.delegate = self; [imageDownloadsInProgress setObject:iconDownloader forKey:indexPath]; [iconDownloader startDownload]; [iconDownloader release]; } } IconDownload.m #import "IconDownloader.h" #import "FeedRecord.h" #define kAppIconHeight 48 @implementation IconDownloader @synthesize feedRecord; @synthesize indexPathInTableView; @synthesize delegate; @synthesize activeDownload; @synthesize imageConnection; #pragma mark - (void)dealloc { [feedRecord release]; [indexPathInTableView release]; [activeDownload release]; [imageConnection cancel]; [imageConnection release]; [super dealloc]; } - (void)startDownload { NSLog(@"%@ %@",@"Started downloading", feedRecord.profilePicture); // this shows in log self.activeDownload = [NSMutableData data]; // alloc+init and start an NSURLConnection; release on completion/failure NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest: [NSURLRequest requestWithURL: [NSURL URLWithString:feedRecord.profilePicture]] delegate:self]; self.imageConnection = conn; NSLog(@"%@",conn); // this shows in log [conn release]; } - (void)cancelDownload { [self.imageConnection cancel]; self.imageConnection = nil; self.activeDownload = nil; } #pragma mark - #pragma mark Download support (NSURLConnectionDelegate) - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"%@ %@",@"Got data for", feedRecord.profilePicture); [self.activeDownload appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"%@",@"Fail!"); // Clear the activeDownload property to allow later attempts self.activeDownload = nil; // Release the connection now that it's finished self.imageConnection = nil; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"%@ %@",@"Done", feedRecord.profilePicture); // Set appIcon and clear temporary data/image UIImage *image = [[UIImage alloc] initWithData:self.activeDownload]; self.feedRecord.image = image; self.activeDownload = nil; [image release]; // Release the connection now that it's finished self.imageConnection = nil; NSLog(@"%@ %@",@"Our delegate is",delegate); // call our delegate and tell it that our icon is ready for display [delegate feedImageDidLoad:self.indexPathInTableView]; } @end Has anyone else experienced anything like this or can identify an issue with my code? Thanks!

    Read the article

  • EXEC_BAD_ACCESS in UITableView cellForRowAtIndexPath

    - by David van Dugteren
    My UITable is returning EXEC_BAD_ACCESS, but why! See this code snippet! Loading the UITableView works fine, so allXYZArray != nil and is populated! Then scrolling the tableview to the bottom and back up causes it to crash, as it goes to reload the method cellForRowAtIndexPath It fails on line: "NSLog(@"allXYZArray::count: %i", [allXYZArray count]);" - (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CellIdentifier"; UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; @try { if (allAdviceArray == nil) { NSLog(@"nil"); allXYZArray = [ToolBox getMergedSortedDictionaries:allXYZGiven SecondDictionary:allXYZSought]; } NSLog(@"%i", [indexPath row]); NSLog(@"allXYZArray::count: %i", [allXYZArray count]);

    Read the article

  • Placemark not giving city name in ios 6

    - by Sawant
    I am using this code in which i am getting Placemark but it not giving the city name. Earlier i am using MKReverse Geocoder to get the placemark in which i am getting the city name but as in ios6 it showing deprecated because the apple developer added every thing in CLLocation. so i used this code. `-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocation *location = [locationManager location]; NSLog(@"location is %@",location); CLGeocoder *fgeo = [[[CLGeocoder alloc] init] autorelease]; // Reverse Geocode a CLLocation to a CLPlacemark [fgeo reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error){ // Make sure the geocoder did not produce an error // before continuing if(!error){ // Iterate through all of the placemarks returned // and output them to the console for(CLPlacemark *placemark in placemarks){ NSLog(@"%@",[placemark description]); city1= [placemark.addressDictionary objectForKey:(NSString*) kABPersonAddressCityKey]; NSLog(@"city is %@",city1); } } else{ // Our geocoder had an error, output a message // to the console NSLog(@"There was a reverse geocoding error\n%@", [error localizedDescription]); } } ]; } ` here as i am seeing in console in NSLog(@"%@",[placemark description]); its giving output like :- abc road name,abc road name, state name,country name. any help please .Thanking in advance.

    Read the article

  • iPhone scrollView won't scroll after keyboard is closed

    - by Rob
    I was trying to implement a way to have the UITextField move up when the keyboard opened so that the user could see what they were typing but after implementing the code - it locks my scroll. The view will scroll when the user first gets to that view but after inputting text and closing the keyboard it locks the view. I suspect that it is a problem somewhere in this code: - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSLog(@"Registering for keyboard events"); // Register for the events [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (keyboardDidShow:) name: UIKeyboardDidShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (keyboardDidHide:) name: UIKeyboardDidHideNotification object:nil]; // Setup content size scrollView.contentSize = CGSizeMake(SCROLLVIEW_CONTENT_WIDTH, SCROLLVIEW_CONTENT_HEIGHT); //Initially the keyboard is hidden keyboardVisible = NO; } -(void) viewWillDisappear:(BOOL)animated { NSLog (@"Unregister for keyboard events"); [[NSNotificationCenter defaultCenter] removeObserver:self]; } //**-------------------------------** - (void) keyboardDidShow: (NSNotification *)notif { NSLog(@"Keyboard is visible"); // If keyboard is visible, return if (keyboardVisible) { NSLog(@"Keyboard is already visible. Ignore notification."); return; } // Get the size of the keyboard. NSDictionary* info = [notif userInfo]; NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey]; CGSize keyboardSize = [aValue CGRectValue].size; // Save the current location so we can restore // when keyboard is dismissed offset = scrollView.contentOffset; // Resize the scroll view to make room for the keyboard CGRect viewFrame = scrollView.frame; viewFrame.size.height -= keyboardSize.height; scrollView.frame = viewFrame; CGRect textFieldRect = [activeField frame]; textFieldRect.origin.y += 10; [scrollView scrollRectToVisible:textFieldRect animated:YES]; NSLog(@"ao fim"); // Keyboard is now visible keyboardVisible = YES; } -(void) keyboardDidHide: (NSNotification *)notif { // Is the keyboard already shown if (!keyboardVisible) { NSLog(@"Keyboard is already hidden. Ignore notification."); return; } // Reset the frame scroll view to its original value scrollView.frame = CGRectMake(0, 0, SCROLLVIEW_CONTENT_WIDTH, SCROLLVIEW_CONTENT_HEIGHT); // Reset the scrollview to previous location scrollView.contentOffset = offset; // Keyboard is no longer visible keyboardVisible = NO; } -(BOOL) textFieldShouldBeginEditing:(UITextField*)textField { activeField = textField; return YES; } I defined the size above the #imports as: #define SCROLLVIEW_CONTENT_HEIGHT 1000 #define SCROLLVIEW_CONTENT_WIDTH 320 Really not sure what the issue is.

    Read the article

  • Problem with XML parser

    - by zp26
    Hi, I have a problem with parsing XML. I have created a program which write a file xml in the project directory. The file XML are correct. (i checked). When i try to read this XML the program crash and return 1 status. I have controlled my 2 path and they are equals. Can you help me please? Thanks so much. #import "PositionIdentifierViewController.h" #import "WriterXML.h" @implementation PositionIdentifierViewController - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { NSString *stringa = [NSString stringWithFormat:@"%@",string]; textArea.text = [textArea.text stringByAppendingString:@"\n"]; textArea.text = [textArea.text stringByAppendingString:stringa]; } -(IBAction)startParsing { NSURL *xmlURL = [NSURL fileURLWithPath:path]; NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; [parser setDelegate:self]; BOOL success = [parser parse]; if(success == YES){ // } [parser release]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; NSArray *tempPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [tempPaths objectAtIndex:0]; path = [documentsDirectoryPath stringByAppendingPathComponent:@"filePosizioni.xml"]; WriterXML *newWriter; newWriter = [[WriterXML alloc]init]; [newWriter saveXML:(NSString*)@"ciao":(float)10:(float)40:(float)70]; [newWriter saveXML:(NSString*)@"pippo":(float)20:(float)50:(float)80]; [newWriter saveXML:(NSString*)@"pluto":(float)30:(float)60:(float)90]; NSLog(path); } - (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. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end #import "WriterXML.h" @implementation WriterXML -(void)saveXML:(NSString*)name:(float)x:(float)y:(float)z{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectoryPath stringByAppendingPathComponent:@"filePosizioni.xml"]; NSFileHandle *myHandle; NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *titoloXML = [NSString stringWithFormat:@"<?xml version=1.0 encoding=UTF-8 ?>"]; NSString *inizioTag = [NSString stringWithFormat:@"\n\n\n<position>"]; NSString *tagName = [NSString stringWithFormat:@"\n <name>%@</name>", name]; NSString *tagX = [NSString stringWithFormat:@"\n <x>%f</x>", x]; NSString *tagY = [NSString stringWithFormat:@"\n <y>%f</y>", y]; NSString *tagZ = [NSString stringWithFormat:@"\n <z>%f</z>", z]; NSString *fineTag= [NSString stringWithFormat:@"\n</position>"]; NSData* dataTitoloXML = [titoloXML dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataInizioTag = [inizioTag dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataName = [tagName dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataX = [tagX dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataY = [tagY dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataZ = [tagZ dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataFineTag = [fineTag dataUsingEncoding: NSASCIIStringEncoding]; if(![fileManager fileExistsAtPath:filePath]) [fileManager createFileAtPath:filePath contents:dataTitoloXML attributes:nil]; myHandle = [NSFileHandle fileHandleForUpdatingAtPath:filePath]; [myHandle seekToEndOfFile]; [myHandle writeData:dataInizioTag]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataName]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataX]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataY]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataZ]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; [myHandle writeData:dataFineTag]; NSLog(@"writeok"); [myHandle seekToEndOfFile]; NSLog(@"zp26 %@",filePath); } @end

    Read the article

  • Append data to file in iPhone app

    - by zp26
    I have a problem. I want to create a file like XML. I have create a code for this but the file not append the information but rewrite and save only the last NSData. Can you help me/ This is my code -(void)salvataggioInXML:(NSString*)name:(float)x:(float)y:(float)z{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectoryPath stringByAppendingPathComponent:@"filePosizioni.xml"]; NSFileHandle *myHandle = [NSFileHandle fileHandleForUpdatingAtPath:filePath]; [myHandle seekToEndOfFile]; NSString *tagName = [NSString stringWithFormat:@"<name>%@<name>", name]; NSString *tagX = [NSString stringWithFormat:@"<x>%f<x>", name]; NSString *tagY = [NSString stringWithFormat:@"<y>%f<y>", name]; NSString *tagZ = [NSString stringWithFormat:@"<z>%f<z>", name]; NSData* dataName = [tagName dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataX = [tagX dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataY = [tagY dataUsingEncoding: NSASCIIStringEncoding]; NSData* dataZ = [tagZ dataUsingEncoding: NSASCIIStringEncoding]; if ([dataName writeToFile:filePath atomically:YES]) NSLog(@"writeok"); [myHandle seekToEndOfFile]; if ([dataX writeToFile:filePath atomically:YES]) NSLog(@"writeok"); [myHandle seekToEndOfFile]; if ([dataY writeToFile:filePath atomically:YES]) NSLog(@"writeok"); [myHandle seekToEndOfFile]; if ([dataZ writeToFile:filePath atomically:YES]) NSLog(@"writeok"); [myHandle seekToEndOfFile]; NSLog(@"zp26 %@",filePath); }

    Read the article

  • How i find the greatest number from six or more digit number?

    - by Rajendra Bhole
    Hi,thanks in advance, I have the code in which i want to find out the greatest number from six numbers, the code as follows, if( (pixels->r == 244 || pixels->g == 242 || pixels->b == 245) || (pixels->r == 236 || pixels->g == 235 || pixels->b == 233) || (pixels->r == 250 || pixels->g == 249 || pixels->b == 247) || (pixels->r == 253 || pixels->g == 251 || pixels->b == 230) || (pixels->r == 253 || pixels->g == 246 || pixels->b == 230) || (pixels->r == 254 || pixels->g == 247 || pixels->b == 229)) { numberOfPixels1++; NSLog( @"Pixel data1 %d", numberOfPixels1); } if( (pixels->r == 250 || pixels->g == 240 || pixels->b == 239) ||(pixels->r == 243 || pixels->g == 234 || pixels->b == 229) || (pixels->r == 244 || pixels->g == 241 || pixels->b == 234) || (pixels->r == 251 || pixels->g == 252 || pixels->b == 244) || (pixels->r == 252 || pixels->g == 248 || pixels->b == 237) || (pixels->r == 254 || pixels->g == 246 || pixels->b == 225)) { numberOfPixels2++; NSLog( @"Pixel data2 %d", numberOfPixels2); } if( (pixels->r == 255 || pixels->g == 249 || pixels->b == 225) ||(pixels->r == 255 || pixels->g == 249 || pixels->b == 225) || (pixels->r == 241 || pixels->g == 231 || pixels->b == 195) || (pixels->r == 239 || pixels->g == 226 || pixels->b == 173) || (pixels->r == 224 || pixels->g == 210 || pixels->b == 147) || (pixels->r == 242 || pixels->g == 226 || pixels->b == 151)) { numberOfPixels3++; NSLog( @"Pixel data3 %d", numberOfPixels3); } if( (pixels->r == 235 || pixels->g == 214 || pixels->b == 159) ||(pixels->r == 235 || pixels->g == 217 || pixels->b == 133) || (pixels->r == 227 || pixels->g == 196 || pixels->b == 103) || (pixels->r == 225 || pixels->g == 193 || pixels->b == 106) || (pixels->r == 223 || pixels->g == 193 || pixels->b == 123) || (pixels->r == 222 || pixels->g == 184 || pixels->b == 119)) { numberOfPixels4++; NSLog( @"Pixel data4 %d", numberOfPixels4); } if( (pixels->r == 199 || pixels->g == 164 || pixels->b == 100) ||(pixels->r == 188 || pixels->g == 151 || pixels->b == 98) || (pixels->r == 156 || pixels->g == 107 || pixels->b == 67) || (pixels->r == 142 || pixels->g == 88 || pixels->b == 62) || (pixels->r == 121 || pixels->g == 77 || pixels->b == 48) || (pixels->r == 100 || pixels->g == 49 || pixels->b == 22)) { numberOfPixels5++; NSLog( @"Pixel data5 %d", numberOfPixels5); } if( (pixels->r == 101 || pixels->g == 48 || pixels->b == 32) ||(pixels->r == 96 || pixels->g == 49 || pixels->b == 33) || (pixels->r == 87 || pixels->g == 50 || pixels->b == 41) || (pixels->r == 64 || pixels->g == 32 || pixels->b == 21) || (pixels->r == 49 || pixels->g == 37 || pixels->b == 41) || (pixels->r == 27 || pixels->g == 28 || pixels->b == 46)) { numberOfPixels6++; NSLog( @"Pixel data6 %d", numberOfPixels6); } I have to find out greatest from numberOfPixels1....numberOfPixels6 from above code. There are any optimum way to find out the greatest number?

    Read the article

  • cant populate cells with an array when i have loaded a second UITableViewController

    - by richard Stephenson
    hi there, im very new to iphone programming, im creating my first app, (a world cup one) the first view is a table view. the cell text label is filled with an array, so it shows all the groups (group a, B, c,ect) then when you select a group, it pulls on another UITableViewcontroller, but whatever i do i cant set the text label of the cells (e.g france,mexico,south africa, etc. infact nothin i do to the cellForRowAtIndexPath makes a difference , could someone tell me what im doing wrong please Thanks `here is my code for the view controller #import "GroupADetailViewController.h" @implementation GroupADetailViewController @synthesize groupLabel = _groupLabel; @synthesize groupADetail = _groupADetail; @synthesize teamsInGroupA; #pragma mark Memory management - (void)dealloc { [_groupADetail release]; [_groupLabel release]; [super dealloc]; } #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Set the number label to show the number data teamsInGroupA = [[NSArray alloc]initWithObjects:@"France",@"Mexico",@"Uruguay",@"South Africa",nil]; NSLog(@"loaded"); // Set the title to also show the number data [[self navigationItem]setTitle:@"Group A"]; //[[self navigationItem]cell.textLabel.text:@"test"]; //[[self navigationItem] setTitle[NSString String } - (void)viewDidUnload { [self setgroupLabel:nil]; } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView { // Return the number of sections in the table view return 1; } - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in a specific section // Since we only have one section, just return the number of rows in the table return 4; NSLog:("count is %d",[teamsInGroupA count]); } - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString *cellIdentifier2 = @"Cell2"; // Reuse an existing cell if one is available for reuse UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier2]; // If no cell was available, create a new one if (cell == nil) { NSLog(@"no cell, creating"); cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier2] autorelease]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; } NSLog(@"cell already there"); // Configure the cell to show the data for this row //[[cell textLabel]setText:[NSString string //[[cell textLabel]setText:[teamsInGroupA objectAtIndex:indexPath.row]]; //NSUInteger row = [indexPath row]; //[cell setText:[[teamsInGroupA objectAtIndex:indexPath:row]retain]]; //cell.textLabel.text:@"Test" [[cell textLabel]setText:[teamsInGroupA objectAtIndex:indexPath.row]]; return cell; } @end #import "GroupADetailViewController.h" @implementation GroupADetailViewController @synthesize groupLabel = _groupLabel; @synthesize groupADetail = _groupADetail; @synthesize teamsInGroupA; #pragma mark Memory management - (void)dealloc { [_groupADetail release]; [_groupLabel release]; [super dealloc]; } #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; // Set the number label to show the number data teamsInGroupA = [[NSArray alloc]initWithObjects:@"France",@"Mexico",@"Uruguay",@"South Africa",nil]; NSLog(@"loaded"); // Set the title to also show the number data [[self navigationItem]setTitle:@"Group A"]; //[[self navigationItem]cell.textLabel.text:@"test"]; //[[self navigationItem] setTitle[NSString String } - (void)viewDidUnload { [self setgroupLabel:nil]; } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView { // Return the number of sections in the table view return 1; } - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in a specific section // Since we only have one section, just return the number of rows in the table return 4; NSLog:("count is %d",[teamsInGroupA count]); } - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString *cellIdentifier2 = @"Cell2"; // Reuse an existing cell if one is available for reuse UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier2]; // If no cell was available, create a new one if (cell == nil) { NSLog(@"no cell, creating"); cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier2] autorelease]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; } NSLog(@"cell already there"); // Configure the cell to show the data for this row //[[cell textLabel]setText:[NSString string //[[cell textLabel]setText:[teamsInGroupA objectAtIndex:indexPath.row]]; //NSUInteger row = [indexPath row]; //[cell setText:[[teamsInGroupA objectAtIndex:indexPath:row]retain]]; //cell.textLabel.text:@"Test" [[cell textLabel]setText:[teamsInGroupA objectAtIndex:indexPath.row]]; return cell; } @end

    Read the article

  • Application crashing on getting updated information from database using timer and storing it on loca

    - by Amit Battan
    In our multi - user application we are continuously interacting with database. We have a common class through which we are sending POST queries to database and obtaining xml files in return. We are using delegates of NSXMLParser to parse the obtained file. The problem with us is we are facing many crashes in it generally when application is idle and changed data in database is being fetched in background through timer which is invoked after every few seconds. We have also dealt with error handling through try and catch but it proves to be of no use in this case and mostly application crashes with following error : Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000020 Strange thing is that many times the fetching of updated data at background works very fine, same methods being successfully executed under similar conditions but suddenly it crashes on one of them. The codes we are using is as follows: // we are using timer in this way: chkOnlineUser=[NSTimer scheduledTimerWithTimeInterval:15 target:mmObject selector:@selector(threadOnlineUser) userInfo:NULL repeats:YES]; // this method being called in timer -(void)threadOnlineUser{//HeartBeat in Thread [NSThread detachNewThreadSelector:@selector(onlineUserRefresh) toTarget:self withObject:nil]; } // this performs actual updation -(void)onlineUserRefresh{ NSAutoreleasePool *pool =[[NSAutoreleasePool alloc]init]; @try{ if(chkTimer==1){ return; } chkTimer=1; if([allUserArray count]==0){ [user parseXMLFileUser:@"all" andFlag:3]; [allUserArray removeAllObjects]; [allUserArray addObjectsFromArray:[user users]]; } [objHeartBeat parseXMLFile:[loginID intValue] timeOut:10]; NSMutableDictionary *tDictOL=[[NSMutableDictionary alloc] init]; tDictOL=[objHeartBeat onLineList]; NSArray *tArray=[[NSArray alloc] init]; tArray=[[tDictOL objectForKey:@"onlineuser"] componentsSeparatedByString:@","]; [loginUserArray removeAllObjects]; for(int l=0;l less than [tArray count] ;l++){ int t;//=[[tArray objectAtIndex:l] intValue]; if([[allUserArray valueForKey:@"Id"] containsObject:[tArray objectAtIndex:l]]){ t = [[allUserArray valueForKey:@"Id"] indexOfObject:[tArray objectAtIndex:l]]; [loginUserArray addObject:[allUserArray objectAtIndex:t]]; } } [onlineTable reloadData]; [logInUserPopUp removeAllItems]; if([loginUserArray count]==1){ [labelLoginUser setStringValue:@"Only you are online"]; [logInUserPopUp setEnabled:YES]; }else{ [labelLoginUser setStringValue:[NSString stringWithFormat:@" %d users online",[loginUserArray count]]]; [logInUserPopUp setEnabled:YES]; } NSMenu *menu = [[NSMenu alloc] initWithTitle:@"menu"]; NSMenuItem *itemOne = [[NSMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""]; [menu addItem:itemOne]; for(int l=0;l less than [loginUserArray count];l++){ NSString *tempStr= [NSString stringWithFormat:@"%@ %@",[[[loginUserArray objectAtIndex:l] objectForKey:@"user_fname"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]],[[[loginUserArray objectAtIndex:l] objectForKey:@"user_lname"] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]]; if(![tempStr isEqualToString:@""]){ NSMenuItem *itemOne = [[NSMenuItem alloc] initWithTitle:tempStr action:NULL keyEquivalent:@""]; [menu addItem:itemOne]; }else if(l==0){ NSMenuItem *itemOne = [[NSMenuItem alloc] initWithTitle:tempStr action:NULL keyEquivalent:@""]; [menu addItem:itemOne]; } } [logInUserPopUp setMenu:menu]; if([lastUpdateTime isEqualToString:@""]){ }else { [self fetchUpdatedInfo:lastUpdateTime]; [self fetchUpdatedGroup:lastUpdateTime];// function same as fetchUpdatedInfo [avObject fetchUpdatedInfo:lastUpdateTime];// function same as fetchUpdatedInfo [esTVObject fetchUpdatedInfo:lastUpdateTime];// function same as fetchUpdatedInfo } lastUpdateTime=[[tDictOL objectForKey:@"lastServerTime"] copy]; } @catch (NSException * e) { [queryByPost insertException:@"MainModule" inFun:@"onlineUserRefresh" excp:[e description] userId:[loginID intValue]]; NSRunAlertPanel(@"Error Panel", @"Main Module- onlineUserRefresh....%@", @"OK", nil, nil,e); } @finally { NSLog(@"Internal Update Before Bye"); chkTimer=0; NSLog(@"Internal Update Bye");// Some time application crashes after this log // Some time application crahses after "Internal Update Bye" log } } // The method which we are using to obtain updated data is of following form: -(void)fetchUpdatedInfo:(NSString *)UpdTime{ @try { if(initAfterLoginComplete==0){ return; } [user parseXMLFileUser:UpdTime andFlag:[loginID intValue]]; [tempUserUpdatedArray removeAllObjects]; [tempUserUpdatedArray addObjectsFromArray:[user users]]; if([tempUserUpdatedArray count]0){ if([contactsView isHidden]){ [topContactImg setImage:[NSImage imageNamed:@"btn_contacts_off_red.png"]]; }else { [topContactImg setImage:[NSImage imageNamed:@"btn_contacts_red.png"]]; } }else { return; } int chkprof=0; for(int l=0;l less than [tempUserUpdatedArray count];l++){ NSArray *tempArr1 = [allUserArray valueForKey:@"Id"]; int s; if([[[tempUserUpdatedArray objectAtIndex:l] objectForKey:@"Id"] intValue]==profile_Id){ chkprof=1; } if([tempArr1 containsObject:[[tempUserUpdatedArray objectAtIndex:l] objectForKey:@"Id"]]){ s = [tempArr1 indexOfObject:[[tempUserUpdatedArray objectAtIndex:l] objectForKey:@"Id"]]; [allUserArray replaceObjectAtIndex:s withObject:[tempUserUpdatedArray objectAtIndex:l]]; }else { [allUserArray addObject:[tempUserUpdatedArray objectAtIndex:l]]; } NSArray *tempArr2 = [tempUser valueForKey:@"Id"]; if([tempArr2 containsObject:[[tempUserUpdatedArray objectAtIndex:l] objectForKey:@"Id"]]){ s = [tempArr2 indexOfObject:[[tempUserUpdatedArray objectAtIndex:l] objectForKey:@"Id"]]; [tempUser replaceObjectAtIndex:s withObject:[tempUserUpdatedArray objectAtIndex:l]]; }else { [tempUser addObject:[tempUserUpdatedArray objectAtIndex:l]]; } } NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"user_fname" ascending:YES]; [tempUser sortUsingDescriptors:[NSMutableArray arrayWithObject:sortDescriptor]]; [userListTableView reloadData]; [groupsArray removeAllObjects]; for(int z=0;z less than [tempGroups count];z++){ NSMutableArray *tempMArr=[[NSMutableArray alloc] init]; for(int l=0;l less than [allUserArray count];l++){ if([[[allUserArray objectAtIndex:l] objectForKey:@"GroupId"] intValue]==[[[tempGroups objectAtIndex:z] objectForKey:@"group_id"] intValue]){ [tempMArr addObject:[allUserArray objectAtIndex:l]]; } } [groupsArray insertObject:tempMArr atIndex:z]; [tempMArr release]; tempMArr= nil; } for(int n=0;n less than [tempGroups count];n++){ [[groupsArray objectAtIndex:n] addObject:[tempGroups objectAtIndex:n]]; } [groupsListOV reloadData]; if(chkprof==1){ [self profileShow:profile_Id]; }else { } [self selectUserInTable:0]; }@catch (NSException * e) { NSRunAlertPanel(@"Error Panel", @"%@", @"OK", nil, nil,e); } } // The method which we are using to frame select query and parse obtained data is: -(void)parseXMLForUser:(int)UId stringVar:(NSString*)stringVar{ @try{ if(queryByPost) [queryByPost release]; queryByPost=[QueryByPost new]; // common class used to invoke method to send request via POST method //obtaining data for xml parsing NSString *query=[NSString stringWithFormat:@"Select * from userinfo update_time = '%@' AND NOT owner_id ='%d' ",stringVar,UId]; NSData *obtainedData=[queryByPost executeQuery:query WithAction:@"query"]; // method invoked to perform post query if(obtainedData==nil){ // data not obtained so return return; } // initializing dictionary to be obtained after parsing if(obtainedDictionary) [obtainedDictionary release]; obtainedDictionary=[NSMutableDictionary new]; // xml parsing if (updatedDataParser) // airportsListParser is an NSXMLParser instance variable [updatedDataParser release]; updatedDataParser = [[NSXMLParser alloc] initWithData:obtainedData]; [updatedDataParser setDelegate:self]; [updatedDataParser setShouldResolveExternalEntities:YES]; BOOL success = [updatedDataParser parse]; } @catch (NSException *e) { NSLog(@"wtihin parseXMLForUser- parseXMLForUser:stringVar: - %@",[e description]); } } //The method which will attempt to interact 4 times with server if interaction with it is found to be unsuccessful , is of following form: -(NSData*)executeQuery:(NSString*)query WithAction:(NSString*)doAction{ NSLog(@"within ExecuteQuery:WithAction: Query is: %@ and Action is: %@",query,doAction); NSString *returnResult; @try { NSString *returnResult; NSMutableURLRequest *postRequest; NSError *error; NSData *searchData; NSHTTPURLResponse *response; postRequest=[self directMySQLQuery:query WithAction:doAction]; // this method sends actual POST request NSLog(@"after directMYSQL in QueryByPost- performQuery... ErrorLogMsg"); searchData = [NSURLConnection sendSynchronousRequest:postRequest returningResponse:&response error:&error]; returnResult = [[NSString alloc] initWithData:searchData encoding:NSASCIIStringEncoding]; NSString *resultToBeCompared=[returnResult stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSLog(@"result obtained - %@/ resultToBeCompared - %@",returnResult,resultToBeCompared); if(![resultToBeCompared isEqualToString:@""]){ }else { sleep(10); postRequest=[self directMySQLQuery:query WithAction:doAction]; searchData = [NSURLConnection sendSynchronousRequest:postRequest returningResponse:&response error:&error]; if(![resultToBeCompared isEqualToString:@""]){ }else { sleep(10); postRequest=[self directMySQLQuery:query WithAction:doAction]; searchData = [NSURLConnection sendSynchronousRequest:postRequest returningResponse:&response error:&error]; if(![resultToBeCompared isEqualToString:@""]){ }else { sleep(10); postRequest=[self directMySQLQuery:query WithAction:doAction]; searchData = [NSURLConnection sendSynchronousRequest:postRequest returningResponse:&response error:&error]; if(![resultToBeCompared isEqualToString:@""]){ }else { sleep(10); postRequest=[self directMySQLQuery:query WithAction:doAction]; searchData = [NSURLConnection sendSynchronousRequest:postRequest returningResponse:&response error:&error]; if(![resultToBeCompared isEqualToString:@""]){ }else { return nil; } } } } } returnResult = [[NSString alloc] initWithData:searchData encoding:NSASCIIStringEncoding]; return searchData; } @catch (NSException * e) { NSLog(@"within QueryByPost , execurteQuery:WithAction - %@",[e description]); return nil; } } // The method which sends POST request to server , is of following form: -(NSMutableURLRequest *)directMySQLQuery:(NSString*)query WithAction:(NSString*)doAction{ @try{ NSLog(@"Query is: %@ and Action is: %@",query,doAction); // some pre initialization NSString *stringBoundary,*contentType; NSURL *cgiUrl ; NSMutableURLRequest *postRequest; NSMutableData *postBody; NSString *ans=@"434"; cgiUrl = [NSURL URLWithString:@"http://keysoftwareservices.com/API.php"]; postRequest = [NSMutableURLRequest requestWithURL:cgiUrl]; [postRequest setHTTPMethod:@"POST"]; stringBoundary = [NSString stringWithString:@"0000ABCQueryxxxxxx"]; contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", stringBoundary]; [postRequest addValue:contentType forHTTPHeaderField: @"Content-Type"]; //setting up the body: postBody = [NSMutableData data]; [postBody appendData:[[NSString stringWithFormat:@"\r\n\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"code\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:ans] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"action\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:doAction] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"devmode\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"devmode"]] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"q\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:query] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; [postRequest setHTTPBody:postBody]; NSLog(@"Direct My SQL ok");// Some time application crashes afte this log //Some time application crashes after "Direct My SQL ok" log return [postRequest mutableCopy]; }@catch (NSException * e) { NSLog(@"NSException %@",e); NSRunAlertPanel(@"Error Panel", @"Within QueryByPost- directMySQLQuery...%@", @"OK", nil, nil,e); return nil; } }

    Read the article

  • touchesBegan doesnt get detected

    - by Muniraj
    I have a viewcontroller like the following. But the touchsBegan doestnt get detected. Can anyone plz tell me what is wrong. - (id)init { if (self = [super init]) self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]; return self; } -(void) viewWillAppear:(BOOL)animated { overlay = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"overlay.png"]] autorelease]; [self.view addSubview:overlay]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // Detect touch anywhere UITouch *touch = [touches anyObject]; // Where is the point touched CGPoint point = [touch locationInView:self.view]; NSLog(@"pointx: %f pointy:%f", point.x, point.y); // Was a tab touched, if so, which one... if (CGRectContainsPoint(CGRectMake(1, 440, 106, 40), point)) NSLog(@"tab 1 touched"); else if (CGRectContainsPoint(CGRectMake(107, 440, 106, 40), point)) NSLog(@"tab 2 touched"); else if (CGRectContainsPoint(CGRectMake(214, 440, 106, 40), point)) NSLog(@"tab 3 touched"); }

    Read the article

  • Objective-C: Scope problems cellForRowAtIndexPath

    - by Mr. McPepperNuts
    How would I set each individual row in cellForRowAtIndexPath to the results of an array populated by a Fetch Request? (Fetch Request made when button is pressed.) - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // ... set up cell code here ... cell.textLabel.text = [results objectAtIndex:indexPath valueForKey:@"name"]; } warning: 'NSArray' may not respond to '-objectAtIndexPath:' Edit: - (NSArray *)SearchDatabaseForText:(NSString *)passdTextToSearchFor{ NSManagedObject *searchObj; XYZAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *managedObjectContext = appDelegate.managedObjectContext; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name contains [cd] %@", passdTextToSearchFor]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entry" inManagedObjectContext:managedObjectContext]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [request setEntity: entity]; [request setPredicate: predicate]; NSError *error; results = [managedObjectContext executeFetchRequest:request error:&error]; // NSLog(@"results %@", results); if([results count] == 0){ NSLog(@"No results found"); searchObj = nil; self.tempString = @"No results found."; }else{ if ([[[results objectAtIndex:0] name] caseInsensitiveCompare:passdTextToSearchFor] == 0) { NSLog(@"results %@", [[results objectAtIndex:0] name]); searchObj = [results objectAtIndex:0]; }else{ NSLog(@"No results found"); self.tempString = @"No results found."; searchObj = nil; } } [tableView reloadData]; [request release]; [sortDescriptors release]; return results; } - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{ textToSearchFor = mySearchBar.text; results = [self SearchDatabaseForText:textToSearchFor]; self.tempString = [myGlobalSearchObject valueForKey:@"name"]; NSLog(@"results count: %d", [results count]); NSLog(@"results 0: %@", [[results objectAtIndex:0] name]); NSLog(@"results 1: %@", [[results objectAtIndex:1] name]); } @end Console prints: 2010-06-10 16:11:18.581 XYZApp[10140:207] results count: 2 2010-06-10 16:11:18.581 XYZApp[10140:207] results 0: BB Bugs 2010-06-10 16:11:18.582 XYZApp[10140:207] results 1: BB Annie Program received signal: “EXC_BAD_ACCESS”. (gdb) Edit 2: BT: #0 0x95a91edb in objc_msgSend () #1 0x03b1fe20 in ?? () #2 0x0043cd2a in -[UITableViewRowData(UITableViewRowDataPrivate) _updateNumSections] () #3 0x0043ca9e in -[UITableViewRowData invalidateAllSections] () #4 0x002fc82f in -[UITableView(_UITableViewPrivate) _updateRowData] () #5 0x002f7313 in -[UITableView noteNumberOfRowsChanged] () #6 0x00301500 in -[UITableView reloadData] () #7 0x00008623 in -[SearchViewController SearchDatabaseForText:] (self=0x3d16190, _cmd=0xf02b, passdTextToSearchFor=0x3b29630) #8 0x000086ad in -[SearchViewController searchBarSearchButtonClicked:] (self=0x3d16190, _cmd=0x16492cc, searchBar=0x3d2dc50) #9 0x0047ac13 in -[UISearchBar(UISearchBarStatic) _searchFieldReturnPressed] () #10 0x0031094e in -[UIControl(Deprecated) sendAction:toTarget:forEvent:] () #11 0x00312f76 in -[UIControl(Internal) _sendActionsForEventMask:withEvent:] () #12 0x0032613b in -[UIFieldEditor webView:shouldInsertText:replacingDOMRange:givenAction:] () #13 0x01d5a72d in __invoking___ () #14 0x01d5a618 in -[NSInvocation invoke] () #15 0x0273fc0a in SendDelegateMessage () #16 0x033168bf in -[_WebSafeForwarder forwardInvocation:] () #17 0x01d7e6f4 in ___forwarding___ () #18 0x01d5a6c2 in __forwarding_prep_0___ () #19 0x03320fd4 in WebEditorClient::shouldInsertText () #20 0x0279dfed in WebCore::Editor::shouldInsertText () #21 0x027b67a5 in WebCore::Editor::insertParagraphSeparator () #22 0x0279d662 in WebCore::EventHandler::defaultTextInputEventHandler () #23 0x0276cee6 in WebCore::EventTargetNode::defaultEventHandler () #24 0x0276cb70 in WebCore::EventTargetNode::dispatchGenericEvent () #25 0x0276c611 in WebCore::EventTargetNode::dispatchEvent () #26 0x0279d327 in WebCore::EventHandler::handleTextInputEvent () #27 0x0279d229 in WebCore::Editor::insertText () #28 0x03320f4d in -[WebHTMLView(WebNSTextInputSupport) insertText:] () #29 0x0279d0b4 in -[WAKResponder tryToPerform:with:] () #30 0x03320a33 in -[WebView(WebViewEditingActions) _performResponderOperation:with:] () #31 0x03320990 in -[WebView(WebViewEditingActions) insertText:] () #32 0x00408231 in -[UIWebDocumentView insertText:] () #33 0x003ccd31 in -[UIKeyboardImpl acceptWord:firstDelete:addString:] () #34 0x003d2c8c in -[UIKeyboardImpl addInputString:fromVariantKey:] () #35 0x004d1a00 in -[UIKeyboardLayoutStar sendStringAction:forKey:] () #36 0x004d0285 in -[UIKeyboardLayoutStar handleHardwareKeyDownFromSimulator:] () #37 0x002b5bcb in -[UIApplication handleEvent:withNewEvent:] () #38 0x002b067f in -[UIApplication sendEvent:] () #39 0x002b7061 in _UIApplicationHandleEvent () #40 0x02542d59 in PurpleEventCallback () #41 0x01d55b80 in CFRunLoopRunSpecific () #42 0x01d54c48 in CFRunLoopRunInMode () #43 0x02541615 in GSEventRunModal () #44 0x025416da in GSEventRun () #45 0x002b7faf in UIApplicationMain () #46 0x00002578 in main (argc=1, argv=0xbfffef5c) at /Users/default/Documents/iPhone Projects/XYZApp/main.m:14

    Read the article

  • XCode sqlite3 - SELECT always return SQLITE_DONE

    - by user573633
    Hi developers.... a noob here asking for help after a day of head-banging.... I am working on an app with sqlite3 database with one database and two tables. I have now come to a step where I want to select from the table with an argument. The code is here: -(NSMutableArray*) getGroupsPeopleWhoseGroupName:(NSString*)gn;{ NSMutableArray *groupedPeopleArray = [[NSMutableArray alloc] init]; const char *sql = "SELECT * FROM Contacts WHERE groupName='?'"; @try { NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *docsDir = [paths objectAtIndex:0]; NSString *theDBPath = [docsDir stringByAppendingPathComponent:@"ContactBook.sqlite"]; if (!(sqlite3_open([theDBPath UTF8String], &database) == SQLITE_OK)) { NSLog(@"An error opening database."); } sqlite3_stmt *st; NSLog(@"debug004 - sqlite3_stmt success."); if (sqlite3_prepare_v2(database, sql, -1, &st, NULL) != SQLITE_OK) { NSLog(@"Error, failed to prepare statement."); } //DB is ready for accessing, now start getting all the info. while (sqlite3_step(st) == SQLITE_ROW) { MyContacts * aContact = [[MyContacts alloc] init]; //get contactID from DB. aContact.contactID = sqlite3_column_int(st, 0); if (sqlite3_column_text(st, 1) != NULL) { aContact.firstName = [NSString stringWithUTF8String:(char *) sqlite3_column_text(st, 1)]; } else { aContact.firstName = @""; } // here retrieve other columns data .... //store these info retrieved into the newly created array. [groupedPeopleArray addObject:aContact]; [aContact release]; } if(sqlite3_finalize(st) != SQLITE_OK) { NSLog(@"Failed to finalize data statement."); } if (sqlite3_close(database) != SQLITE_OK) { NSLog(@"Failed to close database."); } } @catch (NSException *e) { NSLog(@"An exception occurred: %@", [e reason]); return nil; } return groupedPeopleArray;} MyContacts is the class where I put up all the record variables. My problem is sqlite3_step(st) always return SQLITE_DONE, so that it i can never get myContacts. (i verified this by checking the return value). What am I doing wrong here? Many thanks in advance!

    Read the article

  • iOS bluetooth low energy not detecting peripherals

    - by user3712524
    My app won't detect peripherals. Im using light blue to simulate a bluetooth low energy peripheral and my app just won't sense it. I even installed light blue on two devices to make sure it was generating a peripheral signal properly and it is. Any suggestions? My labels are updating and the NSLog is showing that the scanning is starting. Thanks in advance. #import <UIKit/UIKit.h> #import <CoreBluetooth/CoreBluetooth.h> @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UITextField *navDestination; @end #import "ViewController.h" @implementation ViewController - (IBAction)connect:(id)sender { } - (IBAction)navDestination:(id)sender { NSString *destinationText = self.navDestination.text; } - (void)viewDidLoad { } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end #import <UIKit/UIKit.h> #import "ViewController.h" @interface BlueToothViewController : UIViewController @property (strong, nonatomic) CBCentralManager *centralManager; @property (strong, nonatomic) CBPeripheral *discoveredPerepheral; @property (strong, nonatomic) NSMutableData *data; @property (strong, nonatomic) IBOutlet UITextView *textview; @property (weak, nonatomic) IBOutlet UILabel *charLabel; @property (weak, nonatomic) IBOutlet UILabel *isConnected; @property (weak, nonatomic) IBOutlet UILabel *myPeripherals; @property (weak, nonatomic) IBOutlet UILabel *aLabel; - (void)centralManagerDidUpdateState:(CBCentralManager *)central; - (void)centralManger:(CBCentralManager *)central didDiscoverPeripheral: (CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI; -(void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error; -(void)cleanup; -(void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral; -(void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error; -(void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error; -(void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error; -(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error; -(void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error; @end @interface BlueToothViewController () @end @implementation BlueToothViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { _centralManager = [[CBCentralManager alloc]initWithDelegate:self queue:nil options:nil]; _data = [[NSMutableData alloc]init]; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [_centralManager stopScan]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)centralManagerDidUpdateState:(CBCentralManager *)central { //you should test all scenarios if (central.state == CBCentralManagerStateUnknown) { self.aLabel.text = @"I dont do anything because my state is unknown."; return; } if (central.state == CBCentralManagerStatePoweredOn) { //scan for devices [_centralManager scanForPeripheralsWithServices:nil options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES }]; NSLog(@"Scanning Started"); } if (central.state == CBCentralManagerStateResetting) { self.aLabel.text = @"I dont do anything because my state is resetting."; return; } if (central.state == CBCentralManagerStateUnsupported) { self.aLabel.text = @"I dont do anything because my state is unsupported."; return; } if (central.state == CBCentralManagerStateUnauthorized) { self.aLabel.text = @"I dont do anything because my state is unauthorized."; return; } if (central.state == CBCentralManagerStatePoweredOff) { self.aLabel.text = @"I dont do anything because my state is powered off."; return; } } - (void)centralManger:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { NSLog(@"Discovered %@ at %@", peripheral.name, RSSI); self.myPeripherals.text = [NSString stringWithFormat:@"%@%@",peripheral.name, RSSI]; if (_discoveredPerepheral != peripheral) { //save a copy of the peripheral _discoveredPerepheral = peripheral; //and connect NSLog(@"Connecting to peripheral %@", peripheral); [_centralManager connectPeripheral:peripheral options:nil]; self.aLabel.text = [NSString stringWithFormat:@"%@", peripheral]; } } -(void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error { NSLog(@"Failed to connect"); [self cleanup]; } -(void)cleanup { //see if we are subscribed to a characteristic on the peripheral if (_discoveredPerepheral.services != nil) { for (CBService *service in _discoveredPerepheral.services) { if (service.characteristics != nil) { for (CBCharacteristic *characteristic in service.characteristics) { if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:@"508EFF8E-F541-57EF-BD82-B0B4EC504CA9"]]) { if (characteristic.isNotifying) { [_discoveredPerepheral setNotifyValue:NO forCharacteristic:characteristic]; return; } } } } } } [_centralManager cancelPeripheralConnection:_discoveredPerepheral]; } -(void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral { NSLog(@"Connected"); [_centralManager stopScan]; NSLog(@"Scanning stopped"); self.isConnected.text = [NSString stringWithFormat:@"Connected"]; [_data setLength:0]; peripheral.delegate = self; [peripheral discoverServices:nil]; } -(void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error { if (error) { [self cleanup]; return; } for (CBService *service in peripheral.services) { [peripheral discoverCharacteristics:nil forService:service]; } //discover other characteristics } -(void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error { if (error) { [self cleanup]; return; } for (CBCharacteristic *characteristic in service.characteristics) { [peripheral setNotifyValue:YES forCharacteristic:characteristic]; } } -(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { if (error) { NSLog(@"Error"); return; } NSString *stringFromData = [[NSString alloc]initWithData:characteristic.value encoding:NSUTF8StringEncoding]; self.charLabel.text = [NSString stringWithFormat:@"%@", stringFromData]; //Have we got everything we need? if ([stringFromData isEqualToString:@"EOM"]) { [_textview setText:[[NSString alloc]initWithData:self.data encoding:NSUTF8StringEncoding]]; [peripheral setNotifyValue:NO forCharacteristic:characteristic]; [_centralManager cancelPeripheralConnection:peripheral]; } } -(void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { if ([characteristic.UUID isEqual:nil]) { return; } if (characteristic.isNotifying) { NSLog(@"Notification began on %@", characteristic); } else { [_centralManager cancelPeripheralConnection:peripheral]; } } -(void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error { _discoveredPerepheral = nil; self.isConnected.text = [NSString stringWithFormat:@"Connecting..."]; [_centralManager scanForPeripheralsWithServices:nil options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES}]; } @end

    Read the article

  • How do you populate a UIImage view with ASIHTTPRequest given @2x?

    - by Jonathan Page
    I've been trying to load images from a url using ASIHTTPRequest but I always come up with a blank UIImage. I think it might have something to do with iOS automatically choosing the @2x named version of images or vica versa. [ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]]; NSString *url_string = [NSString stringWithFormat:@"http://173.246.100.185/%@", [eventDictionary objectForKey:kEventDescriptionImageURLKey]]; NSURL *url = [NSURL URLWithString:url_string]; __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDownloadCache:[ASIDownloadCache sharedCache]]; [request setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy]; [request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy]; [request setSecondsToCache:86400]; [request setDelegate:self]; [request setCompletionBlock:^{ NSLog(@"Successful Update"); [self makeAssignment]; }]; [request setFailedBlock:^{ NSError *error = [request error]; NSLog(@"%@", [error localizedDescription]); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Update Failed" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; }]; [request startAsynchronous]; NSLog(@"%@", url_string); The makeAssignment method is below. NSString *url_string = [NSString stringWithFormat:@"http://173.246.100.185/%@", [eventDictionary objectForKey:kEventDescriptionImageURLKey]]; NSURL *url = [NSURL URLWithString:url_string]; downloadedImage = [[UIImage alloc] initWithContentsOfFile:[[ASIDownloadCache sharedCache] pathToCachedResponseDataForURL:url]]; NSLog(@"%@", downloadedImage); NSLog(@"%@", [[ASIDownloadCache sharedCache] pathToCachedResponseDataForURL:url]); Nothing I do, including naming images @2x on the server or providing both versions, gets it to load. Any ideas? Has anyone done this before? When I load them locally (from within the package) I don't have any issues. Thanks!

    Read the article

  • Get touches from UIScrollView

    - by Peter Lapisu
    Basically i want to subclass UIScrollView and hande the touches, however, the touch methods dont get called (i searched the web for a solution and i found out people pointing to override the hit test, what i did, but with no result :( ) .h @interface XScroller : UIScrollView @end .m - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *result = nil; for (UIView *child in self.subviews) { if ([child pointInside:point withEvent:event]) { if ((result = [child hitTest:point withEvent:event]) != nil) { break; } } } return result; } - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"BEGAN"); [super touchesBegan:touches withEvent:event]; } - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"MOVED"); [super touchesMoved:touches withEvent:event]; } - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"ENDED"); [super touchesEnded:touches withEvent:event]; } - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"CANCELED"); [super touchesCancelled:touches withEvent:event]; } none of the - (void) touches* methods get called, the scrolling works ok

    Read the article

  • Different results coming out of an init method than those expected. Why does this happen and how can

    - by Mark Reid
    When I run this method the two properties I have are set to (NULL) when I try and access them outside of the if statement. But they are set to 0 and NO if I check them inside the for loop. -(id) init { NSLog(@"Jumping into the init method!"); if (self = [super init]) { NSLog(@"Running the init method extras"); accumulator = 0; NSLog(@"self.accumulator is %g", accumulator); decimal = NO; } NSLog(@"Calc after init is: %@ and %@", self.accumulator, self.decimal); return self; } Any suggestions as to why what comes out is different from what's done in the for loop?

    Read the article

  • iphone web service access

    - by malleswar
    Hi, I have .net webservice methods login and summary. After getting the result from login, I need to show second view and need to call summary method. I am following this tutorial. http://icodeblog.com/2008/11/03/iphone-programming-tutorial-intro-to-soap-web-services/ I created two new classes loginaccess.h and loginaccess.m. @implementation LoginAccess @synthesize ResultString,webData, soapResults, xmlParser; -(NSString*)LoginCheck:(NSString*)userName:(NSString*)pwd { NSString *soapMessage = [NSString stringWithFormat: @"\n" "\n" "\n" "\n" "%@" "%@" "" "\n" "\n",userName,pwd ]; NSLog(soapMessage); NSURL *url = [NSURL URLWithString:@"http://www.XXXXXXXXX.com/service.asmx"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue: @"http://XXXXXXXXm/Login" forHTTPHeaderField:@"SOAPAction"]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if( theConnection ) { webData = [[NSMutableData data] retain]; } else { NSLog(@"theConnection is NULL"); } //[nameInput resignFirstResponder]; return ResultString; } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [webData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [webData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"ERROR with theConenction"); [connection release]; [webData release]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"DONE. Received Bytes: %d", [webData length]); NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; NSLog(theXML); [theXML release]; if( xmlParser ) { [xmlParser release]; } xmlParser = [[NSXMLParser alloc] initWithData: webData]; [xmlParser setDelegate: self]; [xmlParser setShouldResolveExternalEntities: YES]; [xmlParser parse]; [connection release]; [webData release]; } -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName attributes: (NSDictionary *)attributeDict { if( [elementName isEqualToString:@"LoginResult"]) { if(!soapResults) { soapResults = [[NSMutableString alloc] init]; } recordResults = TRUE; } } -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if( recordResults ) { [soapResults appendString: string]; } } -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if( [elementName isEqualToString:@"LoginResult"]) { recordResults = FALSE; ResultString = soapResults; NSLog(@"Login"); [VariableStore setStr:ResultString]; NSLog(soapResults); [soapResults release]; soapResults = nil; } } @end I am calling LoginCheck method and based on result I want to show the second view. Here after finishing of the button touch down event, it enter into did end element, so I am always getting nil value. If I use the same code controller it works fine as I push second view controller in didendelement. Please give me some samples to place the web service calls in differnt class and how to call them in viewcontrollers. Regards, Malleswar

    Read the article

  • Why doesen't the number 2 work in this for-loop?

    - by Emil
    Hello. I have a function that runs trough each element in an array. It's hard to explain, so I'll just paste in the code here: NSLog(@"%@", arraySub); for (NSString *string in arrayFav){ int favoriteLoop = [string intValue] + favCount; NSLog(@"%d", favoriteLoop); id arrayFavObject = [array objectAtIndex:favoriteLoop]; [arrayFavObject retain]; [array removeObjectAtIndex:favoriteLoop]; [array insertObject:arrayFavObject atIndex:0]; [arrayFavObject release]; id arraySubFavObject = [arraySub objectAtIndex:favoriteLoop]; [arraySubFavObject retain]; [arraySub removeObjectAtIndex:favoriteLoop]; [arraySub insertObject:arraySubFavObject atIndex:0]; [arraySubFavObject release]; id arrayLengthFavObject = [arrayLength objectAtIndex:favoriteLoop]; [arrayLengthFavObject retain]; [arrayLength removeObjectAtIndex:favoriteLoop]; [arrayLength insertObject:arrayLengthFavObject atIndex:0]; [arrayLengthFavObject release]; } NSLog(@"%@", arraySub); The array arrayFav contains these strings: "3", "8", "2", "10", "40". Array array contains 92 strings with a name. Array arraySub contains numbers 0 to 91, representing a filename with a title from the array array. Array arrayLength contains 92 strings representing the size of each file from array arraySub. Now, the first NSLog shows, as expected, the numbers 0 to 91. The NSLog-s in the loop shows the numbers 3, 8, 2, 10, 40, also as expected. But here's the odd part: the last NSLog shows these numbers: 40, 10, 0, 8, 3, 1, 2, 4, 5, 6, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91 that is 40, 10, 0, 8, 3, and so on. It was not supposed to be a zero in there, it was supposed to be a 2.. Do you have any idea at why this is happening or a way to fix it? Thank you.

    Read the article

  • Web Url contains Spanish Characters which my NSXMLParser is not parsing

    - by mAc
    I am Parsing Web urls from server and storing them in Strings and then displaying it on Webview. But now when i am parsing Spanish words like http://litofinter.es.milfoil.arvixe.com/litofinter/PDF/Presentación_LITOFINTER_(ES).pdf it is accepting it PDF File Name ++++++ http://litofinter.es.milfoil.arvixe.com/litofinter/PDF/Presentaci PDF File Name ++++++ ón_LITOFINTER_(ES).pdf i.e two different strings... i know i have to make small change that is append the string but i am not able to do it now, can anyone help me out. Here is my code :- - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { currentElement = elementName; if([currentElement isEqualToString:@"category"]) { NSLog(@"Current element in Category:- %@",currentElement); obj = [[Litofinter alloc]init]; obj.productsArray = [[NSMutableArray alloc]init]; } if([currentElement isEqualToString:@"Product"]) { obj.oneObj = [[Products alloc]init]; } } - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if([currentElement isEqualToString:@"Logo"]) { obj.cLogo=[NSString stringWithFormat:@"%@",string]; NSLog(@"Logo to be saved in Array :- %@",obj.cLogo); } if([currentElement isEqualToString:@"Name"]) { obj.cName=[NSString stringWithFormat:@"%@",string]; NSLog(@"Name to be saved in Array :- %@",string); } if([currentElement isEqualToString:@"cid"]) { obj.cId=(int)[NSString stringWithFormat:@"%@",string]; NSLog(@"CID to be saved in Array :- %@",string); } if([currentElement isEqualToString:@"pid"]) { //obj.oneObj.id = (int)[NSString stringWithFormat:@"%@",oneBook.id]; obj.oneObj.id = (int)[oneBook.id intValue]; } if([currentElement isEqualToString:@"Title"]) { obj.oneObj.title = [NSString stringWithFormat:@"%@",string]; } if([currentElement isEqualToString:@"Thumbnail"]) { obj.oneObj.thumbnail= [NSString stringWithFormat:@"%@",string]; } // problem occuriing while parsing Spanish characters... if([currentElement isEqualToString:@"pdf"]) { obj.oneObj.pdf = [NSString stringWithFormat:@"%@",string]; NSLog(@"PDF File Name ++++++ %@",string); } } - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if([elementName isEqualToString:@"category"]) { NSLog(@"Current element in End Element Category:- %@",currentElement); [TableMutableArray addObject:obj]; } if([elementName isEqualToString:@"Product"]) { [obj.productsArray addObject:obj.oneObj]; } currentElement = @""; } I will be thankful to you.

    Read the article

  • UiButton / IBAction - link from a RootView to mainView in Storyboard

    - by webschnecke
    I try to call the main ViewController on my storyboard. In my app there is a additional .h, .m file with no xib or storyboard. In this .m file T craeted a button: UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(home:)forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Show View" forState:UIControlStateNormal]; button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); [self.view addSubview:button]; NSLog(@"Home-Button line 645"); This button should link to my main ViewController in the Storyboard. The view has the identifier HauptMenu. I got no error, but the view doesnt change to my main ViewController. What is wrong? - (IBAction)home:(id)sender { NSLog(@"Button was tapped"); ViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"HauptMenu"]; NSLog(@"1"); [viewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; NSLog(@"2"); [self.navigationController pushViewController:viewController animated:NO]; [viewController release]; NSLog(@"3"); }

    Read the article

  • Help: List contents of iPhone application bundle subpath??

    - by bluepill
    Hi, I am trying to get a listing of the directories contained within a subpath of my application bundle. I've done some searching and this is what I have come up with - (void) contents { NSArray *contents = [[NSBundle mainBundle] pathsForResourcesOfType:nil inDirectory:@"DataDir"]; if (contents = nil) { NSLog(@"Failed: path doesn't exist or error!"); } else { NSString *bundlePathName = [[NSBundle mainBundle] bundlePath]; NSString *dataPathName = [bundlePathName stringByAppendingPathComponent: @"DataDir"]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSMutableArray *directories = [[NSMutableArray alloc] init]; for (NSString *entityName in contents) { NSString *fullEntityName = [dataPathName stringByAppendingPathComponent:entityName]; NSLog(@"entity = %@", fullEntityName); BOOL isDir = NO; [fileManager fileExistsAtPath:fullEntityName isDirectory:(&isDir)]; if (isDir) { [directories addObject:fullEntityName]; NSLog(@" is a directory"); } else { NSLog(@" is not a directory"); } } NSLog(@"Directories = %@", directories); [directories release]; } } As you can see I am trying to get a listing of directories in the app bundle's DataDir subpath. The problem is that I get no strings in my contents NSArray. note: - I am using the simulator - When I manually look in the .app file I can see DataDir and the contents therein - The contents of DataDir are png files and directories that contain png files - The application logic needs to discover the contents of DataDir at runtime - I have also tried using NSArray *contents = [fileManager contentsOfDirectoryAtPath:DataDirPathName error:nil]; and I still get no entries in my contents array Any suggestions/alternative approaches? Thanks.

    Read the article

  • Sending a message from Objective-C and getting the return value?

    - by Nick Brooks
    I have this code NSString *tr = [self sendUrl:@"http://google.com/"]; But for some reason 'tr' will remain nil after it is executed. What am I doing wrong? sendUrl : - (NSString *)sendUrl:(NSString *) uri { NSLog(@"Requesting URI 1 ..."); // Prepare URL request to download statuses from Twitter NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:uri]]; NSLog(@"Requesting URI 2 ..."); // Perform request and get JSON back as a NSData object NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSLog(@"Requesting URI 3 ..."); // Get JSON as a NSString from NSData response NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]; NSLog(@"Requesting URI 4 ..."); return json_string; }

    Read the article

  • Issue Displaying/Hiding Views (Obj-C iPhone Programming)

    - by roswell
    All right all, So I've got a UITableView that is inited in applicationDidFinishLaunching like so: [self showForumList]; Said method does this: -(void)showForumList { ForumList *fl = [ForumList alloc]; [fl initWithNibName:@"ForumList" bundle:[NSBundle mainBundle]]; self.ForumList = fl; [window addSubview:[self.ForumList view]]; [fl release]; }where self.ForumList is previously defined in the interface as ForumList *ForumList;, etc. Now, in ForumList (itself an extension of UITableViewController obviously), I've got didSelectRowAtIndexPath: -- within it I have the following code: Forum *f = [Forum alloc]; NSArray *forums = [f getForumList]; NSDictionary *selectedForum = [forums objectAtIndex:[indexPath row]]; NSString *Url = [selectedForum objectForKey:@"url"]; NSString *Username = [selectedForum objectForKey:@"username"]; NSString *Password = [selectedForum objectForKey:@"password"]; NSLog(@"Identified press on forum %@ (%@/%@)", Url, Username, Password); [self.globalDelegate showForumListFromForumUsingUrl:Url username:Username password:Password]; [self.globalDelegate closeForumList]; NSLog(@"ForumListFromForum init"); Both of the NSLog calls in this function are executed and perform as they should. Now, here is where the issue starts. self.globalDelegate is defined as AppDelegate *globalDelegate; in the Interface specification in my header file. However, [self.globalDelegate showForumListFromForumUsingUrl:username:password] and and [self.globalDelegate closeForumList] are never actually called. They look like so: -(void)closeForumList { NSLog(@"Hiding forum list"); [[self.ForumList view] removeFromSuperview]; } -(void)showForumListFromForumUsingUrl:(NSString *)Url username:(NSString *)Username password:(NSString *)Password { NSLog(@"Showing forum list from forum"); ForumListFromForum *fl = [ForumListFromForum alloc]; [fl initWithNibName:@"ForumListFromForum" bundle:[NSBundle mainBundle]]; [fl initFromForumWithUrl:Url username:Username password:Password]; self.ForumListFromForum = fl; [window addSubview:[self.ForumListFromForum view]]; [fl release]; } The app does not respond to my press and neither of these NSLog calls are made. Any idea where I've gone wrong?

    Read the article

  • UITableView populating EVERY OTHER launch

    - by Joshmattvander
    I am having a problem that I cant seem to get to the bottom of. In my view did load code, I am creating an array and attempting to populate the table. For some reason it only populates the data on EVERY OTHER time the app is run. I put logs in viewDidLoad which runs as does viewWillAppear and outputs the correct count for the array. Also, the UITableView specicic methods get called when it works and they just don't get called when it doesnt work. I cant figure out the root of this problem. Again this occurrence happens exactly 50% of the time. Theres no dynamic data that could be tripping up or anything. #import "InfoViewController.h" @implementation InfoViewController - (void)viewDidLoad { NSLog(@"Info View Loaded"); // This runs infoList = [[NSMutableArray alloc] init]; //Set The Data //Theres 8 similar lines [infoList addObject :[[NSMutableDictionary alloc] initWithObjectsAndKeys: @"Scrubbed", @"name", @"scrubbed", @"url", nil]]; NSLog(@"%d", [infoList count]); // This shows the count correctly every time [super viewDidLoad]; } -(void) viewWillAppear:(BOOL)animated { NSLog(@"Info Will Appear"); // This Runs } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // This WILL NOT RUN when it doesnt work, and DOES show the count when it does run NSLog(@"Counted in numberOfRowsInSection %d", [infoList count]); return [infoList count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"ROW"); static NSString *CellIdentifier = @"infoCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.textLabel.text = [[infoList objectAtIndex:indexPath.row] objectForKey:@"name"]; return cell; } @end

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >