Search Results

Search found 605 results on 25 pages for 'stringwithformat'.

Page 8/25 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Update text on CCLabelTFF end in bad access?

    - by TheDeveloper
    I'm doing a little game in Coco2D and I have a countdown clock Note: As I am just trying to fix a bug, I am not working on cleanup so the timer can stop, etc. Here is my code I'm using to setup the label and start the timer: timer = [CCLabelTTF labelWithString:@"10.0000" fontName:@"Helvetica" fontSize:20]; timerDisplay = timer; timerDisplay.position = ccp(277,310); [self addChild:timerDisplay]; timeLeft = 10; timerObject = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateTimer) userInfo:nil repeats:YES]; Note: timeLeft is a double This is updateTimers's code: -(void)updateTimer { NSLog(@"Got Called!"); timeLeft = timeLeft -0.1; [timer setString:[NSString stringWithFormat:@"%f",timeLeft]]; timerDisplay = timer; timerDisplay.position = ccp(277,310); [self removeChild:timerDisplay cleanup:YES]; //[self addChild:timerDisplay]; if (timeLeft <= 0) { [timerObject invalidate]; } } When I run this I toggle between crashing on this this: [timer setString:[NSString stringWithFormat:@"%f",timeLeft]]; and in the green arrow thing it gives Thread 1: EXEC_BAD_ACCESS (code=2, address=0x8) and 0x197a7ff: movl 16(%edi), %esi and in the green arrow thing it gives Thread 1: EXEC_BAD_ACCESS (code=2, address=0x8)

    Read the article

  • Public class: Makes pointer from integer without cast

    - by meridimus
    I have written a class to help save and load data for the sake of persistence for my iPhone application but I have a problem with some NSUIntegers that I'm passing across. Basically, I have the code to use pointers, but eventually it has to start out being an actual value right? So I get this error warning: passing argument 1 of 'getSaveWithCampaign:andLevel:' makes pointer from integer without a cast My code is laid out like so. (Persistence is the name of the class) NSDictionary *saveData = [Persistence getSaveWithCampaign:currentCampaign andLevel:[indexPath row]]; Here's Persistence.m #import "Persistence.h" @implementation Persistence + (NSString *)dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:kSaveFilename]; } + (NSDictionary *)getSaveWithCampaign:(NSUInteger *)campaign andLevel:(NSUInteger *)level { NSString *filePath = [self dataFilePath]; if([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { NSDictionary *saveData = [[NSDictionary alloc] initWithContentsOfFile:filePath]; NSString *campaignAndLevelKey = [self makeCampaign:campaign andLevelKey:level]; NSDictionary *campaignAndLevelData = [saveData objectForKey:campaignAndLevelKey]; [saveData release]; return campaignAndLevelData; } else { return nil; } } + (NSString *)makeCampaign:(NSUInteger *)campaign andLevelKey:(NSUInteger *)level { return [[NSString stringWithFormat:@"%d - ", campaign+1] stringByAppendingString:[NSString stringWithFormat:@"%d", level+1]]; } @end

    Read the article

  • Properly handling NSURLConnection errors

    - by Cal S
    Hi, I have a simple form interface set up that send username and password information to a server: (working) NSString *postData = [NSString stringWithFormat:@"user=%@&pass=%@",[self urlEncodeValue:sysUsername],[self urlEncodeValue:password]]; NSLog(@"Post data -> %@", postData); /// NSData* postVariables = [postData dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] init] autorelease]; NSString* postLength = [NSString stringWithFormat:@"%d", [postVariables length]]; NSURL* postUrl = [NSURL URLWithString:@"http://localhost/~csmith/cocoa/test.php"]; [request setURL:postUrl]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody: postVariables]; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL]; NSLog(@"Post data SENT & returned -> %@", returnData); How do I handle connection errors such as no internet connection, firewall, etc. Also, does this method use the system-wide proxy settings? Many of my users are behind a proxy. Thanks a lot!

    Read the article

  • Paged UIScrollView with UIImageViews only showing first UIImageVIew

    - by Jonathan Brown
    I am working on a paged UIScrollView, but it only wants to show the first UIImageView within it. I add each UIImageView at an offset of the width of the scroll view, so that should create each page. When run, it says the scroll view is the right number of pages, but the images don't show. Any help would be much appreciated! int numSlides = NUM_TUTORIAL_SLIDES; NSString *fileName; UIImageView *slideImageView; CGRect slideFrame; for (int i = 1; i <= numSlides; i++) { slideFrame.origin.x = self.tutorialScrollView.frame.size.width * (i-1); slideFrame.origin.y = 0; slideFrame.size = self.tutorialScrollView.frame.size; slideImageView = [[UIImageView alloc] initWithFrame:slideFrame]; if([[AppManager sharedManager] is4inchScreen]) { fileName = [NSString stringWithFormat:@"Slide%[email protected]", i]; } else { fileName = [NSString stringWithFormat:@"Slide%[email protected]", i]; } slideImageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileName ofType:nil]]; [self.tutorialScrollView addSubview:slideImageView]; [slideImageView release]; } self.tutorialScrollView.contentSize = CGSizeMake(self.tutorialScrollView.frame.size.width * numSlides, self.tutorialScrollView.frame.size.height); self.tutorialScrollView.delegate = self;

    Read the article

  • how to change the image on click from database

    - by iosdev
    In my application i having multiple image in sq lite database,Since i want to change to the next image on button click,Here my code, -(void)Readthesqlitefile:(NSInteger *)sno { sqlite3 *database;//database object NSString *docpath=[self doccumentspath];//get sqlite path const char *ch=[docpath UTF8String];//string to constant char UTF8string main part to connect DB if (sqlite3_open(ch, &database)==SQLITE_OK) { const char *chstmt="SELECT * FROM animal where rowid= = %d",sno; sqlite3_stmt *sqlstmt;//to execute the above statement if (sqlite3_prepare_v2(database, chstmt, -1, &sqlstmt, NULL)==SQLITE_OK) { while (sqlite3_step(sqlstmt)==SQLITE_ROW) { const char *Bname=(char *)sqlite3_column_text(sqlstmt, 0); //converting const char to nsstring NSString *Bndname=[NSString stringWithFormat:@"%s",Bname]; NSLog(@"Brand Names=%@",Bndname); lb1.text=[NSString stringWithFormat:Bndname]; NSUInteger legnt=sqlite3_column_bytes(sqlstmt, 1); if (legnt>0) { NSData *dt=[NSData dataWithBytes:sqlite3_column_blob(sqlstmt, 1) length:legnt]; clsimg=[UIImage imageWithData:dt];//converting data to image imager.image=clsimg; } else { clsimg=nil; } } } sqlite3_finalize(sqlstmt); } sqlite3_close(database); } Button click function -(IBAction)changenext { int j; for (j=1; j<10; j++) { [self Readthesqlitefile:j]; } } its is not working pls help me to solve it out?

    Read the article

  • NSMutableURLRequest returns null on real device, while returning image on simulator

    - by Yanchi
    I was testing my app that I've been working on for past 2 months. Basically it requests for JSON, that contains info about items. One field of JSON file is image_url. When I want to display this image, I need to download it from another server, that needs additional credentials. So it goes like this- In my cellForRowAtIndexPath I'm doing NSDictionary *aucdict = [jsonAukResults objectAtIndex:indexPath.row]; NSURL *imageURL = [NSURL URLWithString:[aucdict objectForKey:@"img_url"]]; NSString *authPString = [[[NSString stringWithFormat:@"login:password"]dataUsingEncoding:NSUTF8StringEncoding] base64EncodedString]; NSString *verifPString = [NSString stringWithFormat:@"Image %@",authPString]; NSMutableURLRequest *Prequest = [[NSMutableURLRequest alloc] initWithURL:imageURL]; [Prequest setValue:verifPString forHTTPHeaderField:@"Authorization"]; NSError *error = nil; NSURLResponse *resp = nil; NSData *picresult = [NSURLConnection sendSynchronousRequest:Prequest returningResponse:&resp error:&error]; UIImage *imageLoad = [[UIImage alloc] initWithData:picresult]; Now, I just obscured credentials (they are not login:password :)). My problem is, that right now, I get 3 items. All 3 have image on same server. I can get two of them with this code no problem. However third one is problematic, I always get (NULL) imageLoad. On my simulator, everything works fine, I get all 3 pictures. On real device I get error. I tried to NSURLConnection with error and response so I could debug better. This is what I got in my error. Printing description of error: Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “server name” which could put your confidential information at risk." UserInfo=0x1e5a3080 {NSErrorFailingURLStringKey=pictureLink.jpg, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=pictureLink.jpg, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “server name” which could put your confidential information at risk., NSUnderlyingError=0x1e5a30e0 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “server name” which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=} I dont use SSL so Im really confused as what could cause this error. Btw, everything worked fine until now (this is my initial screen, so it's been done for good month and a half). Now I started to do graphics and this problem popped up :(

    Read the article

  • plot negative and positive values in same Y-axis in coreplot ios

    - by user3774439
    I have an issue in converting axis labels to int or float values. This is my Y-Axis. It contains temperature values contains -50, 33, 117, 200. CPTXYAxis *y = axisSet.yAxis; y.labelingPolicy = CPTAxisLabelingPolicyNone; y.orthogonalCoordinateDecimal = CPTDecimalFromUnsignedInteger(1); y.majorGridLineStyle = majorGridLineStyle; y.minorGridLineStyle = minorGridLineStyle; y.minorTicksPerInterval = 0.0; y.labelOffset = 0.0; y.title = @""; y.titleOffset = 0.0; NSMutableSet *yLabels = [NSMutableSet setWithCapacity:4]; NSMutableSet *yLocations = [NSMutableSet setWithCapacity:4]; NSArray *yAxisLabels = [NSArray arrayWithObjects:@"-50", @"33", @"117", @"200", nil]; NSNumberFormatter * nFormatter = [[NSNumberFormatter alloc] init]; [nFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; for ( NSUInteger i = 0; i < [yAxisLabels count]; i++ ) { NSLog(@"%@",[yAxisLabels objectAtIndex:i]); CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[NSString stringWithFormat:@"%@",[yAxisLabels objectAtIndex:i]] textStyle:axisTextStyle]; label.tickLocation = CPTDecimalFromUnsignedInteger(i); label.offset = y.majorTickLength; if (label) { [yLabels addObject:label]; [yLocations addObject:[NSDecimalNumber numberWithUnsignedInteger:i]]; } label = nil; } y.axisLabels = yLabels; y.majorTickLocations = yLocations; y.labelFormatter = nFormatter; Now, my issue is.. I am getting data from the BLE device as temperature values as strings like 50, 60.3, etc... Now I want plot these values from BLE device with the Y-axis values. i am unable convert these Y-axis labels to temperature values. Could you please help me guys...I have tried many time still no luck. Please help me UPDATE:: This is the way I am creating scatterplot: -(void)createScatterPlotsWithIdentifier:(NSString *)identifier color:(CPTColor *)color forGraph:(CPTGraph *)graph forXYPlotSpace:(CPTXYPlotSpace *)plotSpace{ CPTScatterPlot *scatterPlot = [[CPTScatterPlot alloc] init]; scatterPlot.dataSource = self; scatterPlot.identifier = identifier; //Plot a graph with in the plotspace [plotSpace scaleToFitPlots:[NSArray arrayWithObjects:scatterPlot, nil]]; plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromUnsignedInteger(0) length:CPTDecimalFromUnsignedInteger(30)]; plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromUnsignedInteger(-50) length:CPTDecimalFromUnsignedInteger(250)]; CPTMutablePlotRange *xRange = [[self getCoreplotSpace].xRange mutableCopy]; [xRange expandRangeByFactor:CPTDecimalFromCGFloat(-1)]; [self getCoreplotSpace].xRange = xRange; CPTMutableLineStyle *scatterLineStyle = [scatterPlot.dataLineStyle mutableCopy]; scatterLineStyle.lineWidth = 1; scatterLineStyle.lineColor = color; scatterPlot.dataLineStyle = scatterLineStyle; CPTMutableLineStyle *scatterSymbolLineStyle = [CPTMutableLineStyle lineStyle]; scatterSymbolLineStyle.lineColor = color; CPTPlotSymbol *scatterSymbol = [CPTPlotSymbol ellipsePlotSymbol]; scatterSymbol.fill = [CPTFill fillWithColor:color]; scatterSymbol.lineStyle = scatterSymbolLineStyle; scatterSymbol.size = CGSizeMake(2.0f, 2.0f); scatterPlot.plotSymbol = scatterSymbol; [graph addPlot:scatterPlot toPlotSpace:plotSpace]; } Configuring the Y-axis like this: NSMutableSet *yLabels = [NSMutableSet setWithCapacity:4]; NSMutableSet *yLocations = [NSMutableSet setWithCapacity:4]; NSArray *yAxisLabels = [NSArray arrayWithObjects:@"-50", @"33", @"117", @"200", nil]; NSArray *customTickLocations = [NSArray arrayWithObjects:[NSDecimalNumber numberWithUnsignedInt:-50], [NSDecimalNumber numberWithInt:33], [NSDecimalNumber numberWithInt:117], [NSDecimalNumber numberWithInt:200],nil]; for ( NSUInteger i = 0; i < [yAxisLabels count]; i++ ) { NSLog(@"%@",[yAxisLabels objectAtIndex:i]); CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:[NSString stringWithFormat:@"%@",[yAxisLabels objectAtIndex:i]] textStyle:axisTextStyle]; label.tickLocation = CPTDecimalFromInteger([[customTickLocations objectAtIndex:i] integerValue]); label.offset = y.majorTickLength; if (label) { [yLabels addObject:label]; [yLocations addObject:[NSString stringWithFormat:@"%d",[[customTickLocations objectAtIndex:i] integerValue]]]; } label = nil; } y.axisLabels = yLabels; y.majorTickLocations = [NSSet setWithArray:customTickLocations]; Eric, I set the range as you said in CreateSctterPlot method. But In horizontal line on graph are not coming. Could you please help me what I am wrong. Thanks

    Read the article

  • How do I repeatedly move an image by 1 pixel?

    - by Will
    I have a method that is moving a UIImageView called shootImg across the screen: -(IBAction)shoot{ if (appDelegate.shootInt > 0) { if (direction == 1) { shootImg.center = CGPointMake(shootImg.center.x+1, shootImg.center.y); appDelegate.shootInt = appDelegate.shootInt - 1; shootLabel.text = [NSString stringWithFormat:@"%d", appDelegate.shootInt]; } This does seem to work. But it only moves shootImage 1 pixel. What I want to do is make it repeatedly move 1 pixel. I tried a while loop but that didn't seem to work. I'm not using cocos2d or anything like that and if you need to see more code just ask. Thanks :)

    Read the article

  • Sound Delay With AVAudio Player

    - by Will Youmans
    I'm using the following code in my viewDidLoad to load a sound: NSURL * url = [NSURL fileURLWithPath: [NSString stringWithFormat:@"%@/Moto - Hit Sound.mp3", [[NSBundle mainBundle] resourcePath]]]; NSError * error; hitSoundPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error]; hitSoundPlayer.numberOfLoops = 0; Then I'm using this in a void method to play the sound: if(CGRectIntersectsRect(main.frame, enemy1.frame)){ [hitSoundPlayer play]; } This does seem to work, however the first time the sound is played there is a lot of lag and the game stops temporarily. I'm using this same method for when in an IBAction and it works fine, it must be the fact that it's also detecting a collision that makes the sound lag. If I want to be able to play sounds quickly and on the spot without any sort of lag am I doing the right thing? Do I want to use another method? I'm not using any frameworks like cocos2d. If you need to see any more code just ask.

    Read the article

  • NSInvalidArgumentException: *** -[NSPlaceholderString initWithFormat:locale:arguments:]: nil argumen

    - by BU
    I have no idea where in my code is causing this problem. Can someone please take a look and let me know what I am missing? The code is relatively straightforward. +(void)processGetGameOffersByGameWithReply:(NSDictionary *)responseDictionary { GameOffer *gameOffer; @try { SharedResources *s = [SharedResources instance]; GameOffersByGameTableViewController *gameOffersByGameTableViewController = [s gameOffersByGameTableViewController]; NSMutableArray *gameOffersArray = [gameOffersByGameTableViewController gameOffersAsArray]; NSString *dealsCountString = [[responseDictionary valueForKey:@"number_of_deals"] retain]; NSNumber *dealsCount = [[SharedResources convertToNumberFromString:dealsCountString] retain]; int i=0; NSString *keyStringForTitle; NSString *title, *description, *keyStringForDescription; for(int i=0; i < dealsCount; i++) { /*NSString *keyStringForDealID = [NSString stringWithFormat:@"DealID%d", i]; NSString *DealIDString = [responseDictionary valueForKey:keyStringForDealID]; NSNumber *DealID = [[SharedResources convertToNumberFromString:DealIDString] retain];*/ keyStringForTitle = [[NSString alloc] initWithFormat:@"Title%d",i] ; title = [[NSString alloc] initWithFormat:[responseDictionary valueForKey:keyStringForTitle]]; //[[responseDictionary valueForKey:keyStringForTitle] retain]; keyStringForDescription = [[NSString alloc] initWithFormat:@"Description%d", i]; description = [[NSString alloc] initWithFormat:[responseDictionary valueForKey:keyStringForDescription]]; /*NSString *keyStringForGameID = [NSString stringWithFormat:@"GameID%d", i]; NSString *GameIDString = [responseDictionary valueForKey:keyStringForGameID]; NSNumber *GameID = [[SharedResources convertToNumberFromString:GameIDString] retain];*/ gameOffer = [[GameOffer alloc] initWithTitle:title Description:description Image:nil]; //int i =0; SharedResources *s = [SharedResources instance]; [gameOffersArray addObject:[gameOffer retain]]; int j=0; } NSString *temp = nil; int k = 0; //find the navigation controller UINavigationController *myNavigationController = [[s gamesTableViewController] navigationController]; //push the table view controller to the navigation controller; [myNavigationController pushViewController:gameOffersByGameTableViewController animated:YES]; } @catch (NSException *ex) { NSLog(@"Count is %d", [[[[SharedResources instance] gameOffersByGameTableViewController] gameOffersAsArray] count]); NSLog(@"\n%@\n%@", [gameOffer Title], [gameOffer Description] ); [SharedResources LogException:ex]; } } The problem is whenever the program gets done with the for loop, it doesn't execute the "NSString *temp=nil" anymore, it jumps to the catch statement. I tried removing the for loop setting i = 0. The problem doesn't occur anymore. It reaches teh end of the method by adding only one object in the array. The problem only occurs if there's a for loop. In the catch statement, even with the error, I can see that the array is filled properly and the [gameOffer Title] and [gameOffer Description] have the correct values. Thanks so much for your help.

    Read the article

  • Strings in Objective-C++

    - by John Smith
    I just switched my code from Objective-C to Objective-C++. Everything goes swimmingly except for two lines. NSString * text1=[[NSString stringWithFormat:@"%.2f",ymax] UTF8String]; This line complains that error: cannot convert 'const char*' to 'NSString*' in initialization The second error related to the first is from the line: CGContextShowTextAtPoint(context, 2, 8, text1, strlen(text1)); It complains that error: cannot convert 'NSString*' to 'const char*' for argument '1' to 'size_t strlen(const char*)' Is there something I missed in the differences between ObjC and ObjC++?

    Read the article

  • NSData's writeToFile method failing with server address

    - by Ricky
    Hi. I am trying to write an NSData object to a directory like so; [myData writeToFile:[NSString stringWithFormat:@"%@/%@.txt", path, filename] atomically:YES]; I receive no errors or warnings but I am assuming the write fails because the path variable has the format of afp://10.0.0.20/username/Desktop. I am connected to the networked share. Do I need to modify the string or take a different approach here? TIA, Ricky.

    Read the article

  • How to check if variable is a CFString?

    - by Sheehan Alam
    I am trying to set some text on a label descriptionLabel.text = [NSString stringWithFormat:mySTUser.bio]; The bio property of mySTUser is an NSString. Sometimes it is not an NSString when I set it. How can I check if mySTUser.bio is an NSString so I can prevent it from being assigned to my label text?

    Read the article

  • adding zeros in objective-c string formats

    - by Chris
    Hello- Quick question: I am trying to fill in empty spaces with a specific number of zeroes in an NSString stringWithFormat formatting string. For example, I want: @"The number is %d", 5 // I want this to output 'the number is 05' @"the number is %d", 10 // I want this to output 'the number is 10' I know how to do this in Java, but I cant seem to find the same function in objective-c. Any help would be great.

    Read the article

  • IOS - Performance Issues with SVProgressHUD

    - by ScottOBot
    I have a section of code that is producing pour performance and not working as expected. it utilizes the SVProgressHUD from the following github repository at https://github.com/samvermette/SVProgressHUD. I have an area of code where I need to use [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]. I want to have a progress hud displayed before the synchronous request and then dismissed after the request has finished. Here is the code in question: //Display the progress HUB [SVProgressHUD showWithStatus:@"Signing Up..." maskType:SVProgressHUDMaskTypeClear]; NSError* error; NSURLResponse *response = nil; [self setUserCredentials]; // create json object for a users session NSDictionary* session = [NSDictionary dictionaryWithObjectsAndKeys: firstName, @"first_name", lastName, @"last_name", email, @"email", password, @"password", nil]; NSData *jsonSession = [NSJSONSerialization dataWithJSONObject:session options:NSJSONWritingPrettyPrinted error:&error]; NSString *url = [NSString stringWithFormat:@"%@api/v1/users.json", CoffeeURL]; NSURL *URL = [NSURL URLWithString:url]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:[NSString stringWithFormat:@"%d", [jsonSession length]] forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:jsonSession]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSDictionary *JSONResponse = [NSJSONSerialization JSONObjectWithData:[dataString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&error]; NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; NSInteger statusCode = httpResponse.statusCode; NSLog(@"Status: %d", statusCode); if (JSONResponse != nil && statusCode == 200) { //Dismiss progress HUB here [SVProgressHUD dismiss]; return YES; } else { [SVProgressHUD dismiss]; return NO; } For some reason the synchronous request blocks the HUB from being displayed. It displays immediately after the synchronous request happens, unfortunatly this is also when it is dismissed. The behaviour displayed to the user is that the app hangs, waits for the synchronous request to finish, quickly flashes the HUB and then becomes responsive again. How can I fix this issue? I want the SVProgressHUB to be displayed during this hang time, how can I do this?

    Read the article

  • SnowLeopard Xcode warning: "format not a string literal and no format arguments"

    - by Justin Galzic
    Since upgrading to the latest XCode 3.2.1 and SnowLeopard, I've been getting the warning, "format not a string literal and no format arguments" on the following: NSError *error = nil; if (![self.managedObjectContext save:&error]) { NSLog([NSString stringWithFormat:@"%@ %@, %@", errorMsgFormat, error, [error userInfo]]); } If 'errorMsgFormat' is an NSString with format specifiers (eg: "print me like this: %@"), what is wrong with the above NSLog statement? And what is the recommended way to fix it so that the warning isn't generated?

    Read the article

  • iPhone UIImage upload to web service

    - by user347635
    Hi all, I worked on this for several hours today and I'm pretty close to a solution but clearly need some help from someone who's pulled this off. I'm trying to post an image to a web service from the iPhone. I'll post the code first then explain everything I've tried: NSData *imageData = UIImageJPEGRepresentation(barCodePic, .9); NSString *soapMsg = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><WriteImage xmlns=\"http://myserver/imagewebservice/\"><ImgIn>%@</ImgIn></WriteImage></soap:Body></soap:Envelope>", [NSData dataWithData:imageData] ]; NSURL *url = [NSURL URLWithString:@"http://myserver/imagewebservice/service1.asmx"]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]]; [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [req addValue:@"http://myserver/imagewebservice/WriteImage" forHTTPHeaderField:@"SOAPAction"]; [req addValue:msgLength forHTTPHeaderField:@"Content-Length"]; [req setHTTPMethod:@"POST"]; [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]]; conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; if (conn) { webData = [[NSMutableData data] retain]; } First thing, this code works fine for anything but an image. The web service is running on my local network and I can change the source code at will and if I change the "ImgIn" parameter to a string and pass a string in, everything works fine, I get a return value no problem. So there are no connectivity issues at all, I'm able to call and get data from this web service on this server no problems. But I need to upload an image to this web service via the ImgIn parameter, so the above code is my best shot so far. I also have didReceiveResponse, didReceiveData, didFailWithError, etc all being handled. The above code fires off didRecieveResponse every time. However didReceiveData is never fired and it's like the web service itself never even runs. When I debug the web service itself, it runs and debugs fine when I use a string parameter, but with the image parameter, it never even debugs when I call it. It's almost like the ImgIn parameter is too long (it's huge when I output it to the screen) and the web service just chokes on it. I've read about having to encode to Base64 when using this method, but I can't find any good links on how that's done. If that's what I'm doing wrong, can you PLEASE provide code as to how to do this, not just "you need to use Base64", I'd really appreciate it as I can find almost nothing on how to implement this with an example. Other than that, I'm kind of lost, it seems like I'm doing everything else right. Please help! Thanks

    Read the article

  • Adding UIView animation mysteriously changes starting frame

    - by clozach
    I'm working on an app that shows a thumbnail of a photo taken by the user. In order to show a seemless transition from the full-screen image shown in the UIImagePickerController to the thumbnail, I set the frame on my copy of the image to [[UIScreen mainScreen] bounds] and then change the frame to match the frame of an invisible button. (The button allows users to re-take their photo by tapping the thumbnail image.) The trouble is that the starting x-origin of my UIImageView (imageView) is mysteriously starting nearly offscreen to the left: As you can see from the alert, the imageView purports to be located at (0,0), yet it's displaying at something like (-255,0). Here's the code: CGRect frame = [[UIScreen mainScreen] bounds]; imageView.frame = frame; [[[[UIAlertView alloc] initWithTitle:@"Yo!" message:[NSString stringWithFormat:@"starting frame:%@",NSStringFromCGRect(imageView.frame)] delegate:nil cancelButtonTitle:@"K." otherButtonTitles:nil] autorelease] show]; // Slide the enlarged image seamlessly "onto" the photo button [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1000]; [UIView setAnimationDelay:.5]; imageView.frame = pictureButton.frame; [UIView commitAnimations]; As if to taunt me, the image actually does go full screen if I comment out the animation code: CGRect frame = [[UIScreen mainScreen] bounds]; imageView.frame = frame; [[[[UIAlertView alloc] initWithTitle:@"Yo!" message:[NSString stringWithFormat:@"starting frame:%@",NSStringFromCGRect(imageView.frame)] delegate:nil cancelButtonTitle:@"K." otherButtonTitles:nil] autorelease] show]; // Slide the enlarged image seamlessly "onto" the photo button // [UIView beginAnimations:nil context:nil]; // [UIView setAnimationDuration:1000]; // [UIView setAnimationDelay:.5]; // // imageView.frame = pictureButton.frame; // // [UIView commitAnimations]; (Note: animationDuration will of course be set to something more like .5 in production, not 1000 seconds.) Update — Other weirdness worth mentioning in case it's relevant: It turns out the offset changes depending on the orientation of the camera when the photo was taken. If I take the picture with the phone upside-down, for instance, then the image gets offset vertically as well as horizontally. The picker seems to be filling the image's imageOrientation incorrectly: I have to hold the phone sideways, Home button on the left, to get an image with UIImageOrientationUp. At one point I experimented with setting imageView.clipsToBounds = YES;, which revealed that my image view's frame is in fact correct. Rather, it's the UIImage's placement within the UIImageView that gets offset. Fwiw, the image view's contentMode is the default, UIViewContentModeScaleToFill.

    Read the article

  • NSString - max 1 decimal of a float

    - by ncohen
    Hi everyone, I would like to use a float in a NSString. I used the stringWithFormat and a %f to integrate my float into the NSString. The problem is that I would like to display only one decimal (%.1f) but when there is no decimals I don't want to display a '.0' . How can I do that? Thanks

    Read the article

  • cocoa - converting a double to string

    - by Mike
    I have a double number and I would like to convert it to string. The number is, for example, something like 24.043333332154465777... but if I convert it to string using something like NSString *myString = [NSString stringWithFormat:@"%f", myDouble]; The string is just 24.043333 how do I get a full string the corresponds to the whole double number? What other methods do I have to convert this?

    Read the article

  • How do I send SMS without launching Text application?

    - by Thomas
    Hello all: I am developing a simple application which has to send an SMS message from the app itself instead of launching the native Text app. Here's my action now. What should I change to achieve my desired functionality? -(IBAction)startButtonPressed { NSString *phoneNumber = @"13136296693"; NSString *url = [NSString stringWithFormat: @"sms:%@",phoneNumber]; NSLog(@"Send SMS to: %@ ", url); [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; } Thanks! Thomas

    Read the article

  • error while soap request call

    - by Jayshree
    Hello. I am trying to make a soap call. Its a very basic call wit Welcome User output. The return value is in xml format. and i am getting the following error. can anyone plz tell me what this error means. The following code shows the soap request and post request that i have made NSString *soapMessage = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" "<soap:Body>\n" "<WelcomeXML xmlns=\"http://qa2.alliancetek.com/phpwebservice/index.php\">\n" "<name>" "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<message>\n" "<name>Hitesh</name>\n" "</message>\n" "</name>" "</WelcomeXML>\n" "</soap:Body>\n" "</soap:Envelope>\n"]; NSLog(@"%@",soapMessage); NSURL *url = [NSURL URLWithString:@"http://qa2.alliancetek.com/phpwebservice/index.php"]; 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://qa2.alliancetek.com/phpwebservice/index.php/WelcomeXML" forHTTPHeaderField:@"SOAPAction"]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; Following is the Error that i am getting : <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">error in msg parsing: XML error parsing SOAP payload on line 5: Reserved XML Name</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> plz help me. I have wasted 2 days on a simple code like this.

    Read the article

  • How can I use this downloaded Class(es) on my Prototype Routine?

    - by O.C.
    I'm a newbie and I'm in need of some help. I'm working on a prototype for an app, but I'm learning at the same time. I want to display a popup image over a given UIView, but I would like it to behave like the UIAlertView or like the Facebook Connect for iPhone modal popup window, in that it has a bouncy, rubbber-band-like animation to it. I was able to find the following class(es) on the net, from someone who was trying to do something similar. He/she put this together, but there was no Demo, no instructions nor a way to contact them. Being that I am so new, I don't have any idea as to how to incorporate this into my code. This is the routine where I need the bouncy image to appear... //======================================================== // // productDetail // - (void) showProductDetail { _productDetailIndex++; if (_productDetailIndex > 7) { return; } else if (_productDetailIndex == 1) { NSString* filename = [NSString stringWithFormat:@"images/ICS_CatalogApp_0%d_ProductDetailPopup.png", _productDetailIndex]; [_productDetail setImageWithName:filename]; _productDetail.transform = CGAffineTransformMakeScale(0.1,0.1); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; // other animations goes here _productDetail.transform = CGAffineTransformMakeScale(1,1); // other animations goes here [UIView commitAnimations]; } NSString* filename = [NSString stringWithFormat:@"images/ICS_CatalogApp_0%d_ProductDetailPopup.png", _productDetailIndex]; [_productDetail setImageWithName:filename]; _productDetail.x = (self.width - _productDetail.width); _productDetail.y = (self.height - _productDetail.height); } and here is the code I found... float pulsesteps[3] = { 0.2, 1/15., 1/7.5 }; - (void) pulse { self.transform = CGAffineTransformMakeScale(0.6, 0.6); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:pulsesteps[0]]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(pulseGrowAnimationDidStop:finished:context:)]; self.transform = CGAffineTransformMakeScale(1.1, 1.1); [UIView commitAnimations]; } - (void)pulseGrowAnimationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:pulsesteps[1]]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(pulseShrinkAnimationDidStop:finished:context:)]; self.transform = CGAffineTransformMakeScale(0.9, 0.9); [UIView commitAnimations]; } - (void)pulseShrinkAnimationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:pulsesteps[2]]; self.transform = CGAffineTransformIdentity; [UIView commitAnimations]; } My routine is based on the Prototyping class given by Apple during WWDC 09. It may not be "correct" but it works as is. I just would like to add the animation to this image/screen to really make the concept clear.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >