Search Results

Search found 477 results on 20 pages for 'nsdata'.

Page 11/20 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • iPhone UIWebView: loadData does not work with certain types (Excel, MSWord, PPT, RTF)

    - by Thomas Tempelmann
    My task is to display the supported document types on an iPhone with OS 3.x, such as .pdf, .rtf, .doc, .ppt, .png, .tiff etc. Now, I have stored these files only encrypted on disk. For security reasons, I want to avoid storing them unencrypted on disk. Hence, I prefer to use loadData:MIMEType:textEncodingName:baseURL: instead of loadRequest: to display the document because loadData allows me to pass the content in a NSData object, i.e. I can decrypt the file in memory and have no need to store it on disk, as it would be required when using loadRequest. The problem is that loadData does not appear to work with all file types: Testing shows that all picture types seem to work fine, as well as PDFs, while the more complex types don't. I get a errors such as: NSURLErrorDomain Code=100 NSURLErrorDomain Code=102 WebView appears to need a truly working URL for accessing the documents as a file, despite me offering all content via the NSData object already. Here's the code I use to display the content: [webView loadData:data MIMEType:type textEncodingName:@"utf-8" baseURL:nil]; The mime-type is properly set, e.g. to "application/msword" for .doc files. Does anyone know how I could get loadData to work with all types that loadRequest supports? Or, alternatively, is there some way I can tell which types do work for sure (i.e. officially sanctioned by Apple) with loadData? Then I can work twofold, creating a temp unencrypted file only for those cases that loadData won't like. Update Looks like I'm not the first one running into this. See here: http://osdir.com/ml/iPhoneSDKDevelopment/2010-03/msg00216.html So, I guess, that's the status quo, and nothing I can do about it. Someone suggested a work-around which might work, though: http://osdir.com/ml/iPhoneSDKDevelopment/2010-03/msg00219.html Basically, the idea is to provide a tiny http server that serves the file (from memory in my case), and then use loadRequest. This is probably a bit more memory-intensive, though, as both the server and the webview will probably both hold the entire contents in memory as two copies then, as opposed to using loadData, where both would rather share the same data object. (Mind you, I'll have to hold the decrypted data in memory, that's the whole point here).

    Read the article

  • I get EXC_BAD_ACCESS when MaxConcurrentOperationCount > 1

    - by kudorgyozo
    Hello i am using NSOperationQueue to download images in the background. I have created a custom NSOperation to download the images. I put the images in table cells. The problem is if I do [operationQueue setMaxConcurrentOperationCount: 10] and i scroll down several cells the program crashes with EXC_BAD_ACCESS. Every time it crashes at the same place in the table. There are 3 cells one after the other which are for the same company and have the same logo so basically it should download the images 3 times. Every other time it works fine. - (void) main { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSURL *url = [[NSURL alloc] initWithString:self.imageURL]; debugLog(@"downloading image: %@", self.imageURL); //NSError *error = nil; NSData *data = [[NSData alloc] initWithContentsOfURL:url]; [url release]; UIImage *image = [[UIImage alloc] initWithData:data]; [data release]; if (image) { if (image.size.width != ICONWIDTH && image.size.height != ICONHEIGHT) { UIImage *resizedImage; CGSize itemSize = CGSizeMake(ICONWIDTH, ICONHEIGHT); UIGraphicsBeginImageContext(itemSize); CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height); [image drawInRect:imageRect]; resizedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); self.theImage = resizedImage; } else { self.theImage = image; } [image release]; } [delegate didFinishDownloadingImage: self]; [pool release]; } This is how i handle downloading the images. If i comment out [delegate didFinishDownloadingImage: self]; in the function above it doesn't crash but of course it is useless. -(void) didFinishDownloadingImage:(ImageDownloadOperation *) imageDownloader { [self performSelectorOnMainThread: @selector(handleDidFinishDownloadingImage:) withObject: imageDownloader waitUntilDone: FALSE]; } -(void) handleDidFinishDownloadingImage:(ImageDownloadOperation *)imageDownloadOperation { NSArray *visiblePaths = [self.myTableView indexPathsForVisibleRows]; CompanyImgDownloaderState *stateObject = (CompanyImgDownloaderState *)[imageDownloadOperation stateObject]; if ([visiblePaths containsObject: stateObject.indexPath]) { //debugLog(@"didFinishDownloadingImage %@ %@", imageDownloader.theImage); UITableViewCell *cell = [self.myTableView cellForRowAtIndexPath: stateObject.indexPath]; UIImageView *imageView = (UIImageView *)[cell viewWithTag: 1]; if (imageDownloadOperation.theImage) { imageView.image = imageDownloadOperation.theImage; stateObject.company.icon = imageDownloadOperation.theImage; } else { imageView.image = [(TestWebServiceAppDelegate *)[[UIApplication sharedApplication] delegate] getCylexIcon]; stateObject.company.icon = [(TestWebServiceAppDelegate *)[[UIApplication sharedApplication] delegate] getCylexIcon]; } } }

    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

  • view .txt, .pdf files in iphone

    - by Ekra
    Hi friends, I am getting the data of the file from network and receiving it in NSData(not saving it any were). I want to view the files without saving it anywere. I tried it with UIWebView but with no success [webView loadData:data_ MIMEType:@"text" textEncodingName:@"UTF-8" baseURL:nil]; Any hint in right direction would be highly appreciated.

    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

  • Using GameKit to transfer CoreData data between iPhones, via NSDictionary

    - by OscarTheGrouch
    I have an application where I would like to exchange information, managed via Core Data, between two iPhones. First turning the Core Data object to an NSDictionary (something very simple that gets turned into NSData to be transferred). My CoreData has 3 string attributes, 2 image attributes that are transformables. I have looked through the NSDictionary API but have not had any luck with it, creating or adding the CoreData information to it. Any help or sample code regarding this would be greatly appreciated.

    Read the article

  • How to Pass byte array as parameter in url in iPhone?

    - by Jindal
    I am using following code to get bytes array. thx to this post. Data *data = [NSData dataWithContentsOfFile:filePath]; NSUInteger len = [data length]; Byte *byteData = (Byte*)malloc(len); memcpy(byteData, [data bytes], len); it is the right method to do so? Now, How i can pass bytes array into url? Thank You for Help,

    Read the article

  • NSObject release destroys local copy of object's data

    - by Spider-Paddy
    I know this is something stupid on my part but I don't get what's happening. I create an object that fetches data & puts it into an array in a specific format, since it fetches asynchronously (has to download & parse data) I put a delegate method into the object that needs the data so that the data fetching object copies it's formatted array into an array in the calling object. The problem is that when the data fetching object is released, the copy it created in the caller is being erased, code is: In .h file @property (nonatomic, retain) NSArray *imagesDataSource; In .m file // Fetch item details ImagesParser *imagesParserObject = [[ImagesParser alloc] init:self]; [imagesParserObject getArticleImagesOfArticleId:(NSInteger)currentArticleId]; [imagesParserObject release] <-- problematic release // Called by parser when images parsing is finished -(void)imagesDataTransferComplete:(ImagesParser *)imagesParserObject { self.imagesDataSource = [ImagesParserObject.returnedArray copy]; // copy array to local variable // If there are more pics, they must be assembled in an array for possible UIImageView animation NSInteger picCount = [imagesDataSource count]; if(picCount > 1) // 1 image is assumed to be the pic already displayed { // Build image array NSMutableArray *tempPicArray = [[NSMutableArray alloc] init]; // Temp space to hold images while building for(int i = 0; i < picCount; i++) { // Get Nr from only article in detailDataSource & pic name (Small) from each item in imagesDataSource NSString *picAddress = [NSString stringWithFormat:@"http://some.url.com/shopdata/image/article/%@/%@", [[detailDataSource objectAtIndex:0] objectForKey:@"Nr"], [[imagesDataSource objectAtIndex:i] objectForKey:@"Small"]]; NSURL *picURL = [NSURL URLWithString:picAddress]; NSData *picData = [NSData dataWithContentsOfURL:picURL]; [tempPicArray addObject:[UIImage imageWithData:picData]]; } imagesArray = [tempPicArray copy]; // copy makes immutable copy of array [tempPicArray release]; currentPicIndex = 0; // Assume first pic is pic already being shown } else imagesArray = nil; // No need for a needless pic array // Remove please wait message [pleaseWaitViewControllerObject.view removeFromSuperview]; } I put in tons of NSLog lines to keep track of what was going on & self.imagesDataSource is populated with the returned array but when the parser object is released self.imagesDataSource becomes empty. I thought self.imagesDataSource = [ImagesParserObject.returnedArray copy]; is supposed to make an independant object, like as if it was alloc, init'ed, so that self.imagesDataSource is not just a pointer to the parser's array but is it's own array. So why does the release of the parser object clear the copy of the array. (I checked & double checked that it's not something overwriting self.imagesDataSource, commenting out [imagesParserObject release] consistently fixes the problem) Also, I have exactly the same problem with self.detailDataSource which is declared & populated in the exact same way as self.imagesDataSource I thought that once I call the parser I could release it because the caller no longer needs to refer to it, all further activity is carried out by the parser object through it's delegate method, what am I doing wrong?

    Read the article

  • Loading .png image from array of uint8_t into OpenGL ES texture

    - by unknownthreat
    Normally, when we want to load a texture for OpenGL ES with .png, we simply add the .png images into XCode. The .png files will be altered for optimization by XCode and these altered png files can loaded into OpenGL ES texture during the runtime. However, what I am trying to do is quite different. I am trying to load a .png file that is not from the prebuilt/compile. The png file will be transmitted externally from UDP, and it will be in the form of array of bytes. I am very sure that the png is transferred correctly, but when it comes to displaying the png image in the form of the OpenGL ES texture, the image somehow shows incorrectly. The colors that are being sent are presented but the positions are somehow very incorrect. However, the position of the colors still retain some aspects of the original position. Here: The left image shows the original .png, while the right shows the png being displayed on iPhone using OpenGL ES Texture. It looks more like the png data is not being decoded or incorrectly processed. Below is OpenGL ES code for turning the image into texture: - (void) setTextureFromImageByte: (uint8_t*)imageByte{ if (self = [super init]){ NSData* imageData = [[NSData alloc] initWithBytes: imageByte length: imageLength]; UIImage* img = [[UIImage alloc] initWithData: imageData]; CGImageRef image = img.CGImage; int width = 512; int height = 512; if (image){ int tempWidth = (int)width, tempHeight = (int)height; if ((tempWidth & (tempWidth - 1)) != 0 ){ NSLog(@"CAUTION! width is not power of 2. width == %d", tempWidth); }else if ((tempHeight & (tempHeight - 1)) != 0 ){ NSLog(@"CAUTION! height is not power of 2. height == %d", tempHeight); }else{ void *spriteData = calloc(width * 4, height * 4); CGContextRef spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width*4, CGImageGetColorSpace(image), kCGImageAlphaPremultipliedLast); CGContextDrawImage(spriteContext, CGRectMake(0.0, 0.0, width, height), image); CGContextRelease(spriteContext); glBindTexture(GL_TEXTURE_2D, 1); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 320, 435, GL_RGBA, GL_UNSIGNED_BYTE, spriteData); free(spriteData); } }else NSLog(@"ERROR: Image not loaded..."); [img release]; [imageData release]; } } So does anyone knows how to deal with this? Is it because of iPhone only accepts altered png from XCode? What can we do in this case in order to make the png image be able to display correctly?

    Read the article

  • Why does UIWebKit throw a structuralComplexityContribution exception?

    - by Axeva
    I've got a simple UIWebView in my iPhone app that's loading a XHTML document with some SGV embeded. This all works find on the desktop version of Safari, but it crashes in a UIWebView. Here is the Objective C: NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"]; NSData *fileData = [NSData dataWithContentsOfFile: path]; [svgView loadData: fileData MIMEType: @"text/xml" textEncodingName: @"UTF-8" baseURL: [NSURL fileURLWithPath: path]]; I also tried a MIMEType of application/xhtml+xml, but it didn't help. Here is the HTML: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>XTech SVG Demo</title> </head> <body> <svg xmlns="http://www.w3.org/2000/svg"> <g style="fill-opacity:0.7;"> <circle cx="6.5cm" cy="2cm" r="100" style="fill:red; stroke:black; stroke-width:0.1cm" transform="translate(0,50)" /> <circle cx="6.5cm" cy="2cm" r="100" style="fill:blue; stroke:black; stroke-width:0.1cm" transform="translate(70,150)" /> <circle cx="6.5cm" cy="2cm" r="100" style="fill:green; stroke:black; stroke-width:0.1cm" transform="translate(-70,150)"/> </g> </svg> </body> </html> All very basic stuff. When it loads on the iPhone, however, it crashes with this error: 2010-03-31 10:37:10.252 ColorDoodle[2014:20b] -[DOMElement structuralComplexityContribution]: unrecognized selector sent to instance 0x3e51b60 2010-03-31 10:37:10.253 ColorDoodle[2014:20b] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[DOMElement structuralComplexityContribution]: unrecognized selector sent to instance 0x3e51b60' Any idea why? Is this a bug in the rendering engine of the UIWebView? I don't see anything too odd here. * Updated * There is definitely something screwy going on here. If I add this bit of code just inside the tag, it works fine: <form> </form> Take that code back out, and it crashes again.

    Read the article

  • Getting Data From Webpages?

    - by fuzzygoat
    When looking to get data from a web page whats the recommended method if the page does not provide a structured data feed? Am I right in thinking that its just a case of doing an NSURLRequest and then hacking what you need out of the responseData(NSData*)? I am not too concerned about the implementation in Xcode, I am more curious about actually collecting the data, before I start coding a "hunt & peck" through a list of data. gary

    Read the article

  • Can MFMailComposeViewController attach an XML doc to an HTML message?

    - by Luther Baker
    I am creating an email in MFMaiilComposeViewController and if I simply create some html snippets and assign them to the message body - all is well. The resulting email (in GMail and Yahoo) looks like the original HTML I sent. [mailMan_ setMessageBody:body isHTML:YES]; On the other hand, if I also include an XML attachment, my email reader renders everything as plain text … including, the XML inlined. IE: my mail client (GMail, Yahoo) shows the raw HTHML and XML tags - including html tags that I didn't supply - ie: the html, head, body tags the iPhone provides around the content: NSData *opmlData = [[NSData alloc] initWithData:[opml dataUsingEncoding:NSUTF8StringEncoding]]; NSString *fileName = [NSString stringWithFormat:@"%f.opml", [NSDate timeIntervalSinceReferenceDate]]; [mailMan_ addAttachmentData:opmlData mimeType:@"text/xml" fileName:fileName]; I pop3'd the mails to see what was happening and found that WITHOUT an attachment, the resulting html section of the email contains this block: --0-1682099714-1273329398=:59784 Content-Type: text/html; charset=us-ascii <html><body bgcolor="#FFFFFF"><div><h2 style="b while on the other hand, WITH the XML attachment, the iPhone is sending this: --0-881105825-1273328091=:50337 Content-Type: text/plain; charset=us-ascii <html><body bgcolor="#FFFFFF"><div><h2 style="bac Notice the difference? Look at the Content-Type … text/html vs text/plain. It looks like when I include an XML attachment, the iPhone is errantly tagging the HTML version of the body as plain text! Just to clarify, technically, both with and without the attachment, the iPhone also includes this: --0-881105825-1273328091=:50337 Content-Type: text/plain; charset=us-ascii Notebook Carpentry Bathroom floor tile Bathroom wall tile Scrape thinset But this obviously isn't where the problem lies. Am I doing something wrong? What must I do to actually "attach" XML without the iPhone labeling the entire HTML body as plain text. I tried reversing the assignments (attachment first and then body) but no luck. For what it's worth, the email looks perfect from the iPhone's sending interface. Indeed, the HTML renders correctly and the attachment looks like a little icon at the bottom of the message. This problem has more to do with what the iPhone is actually sending.

    Read the article

  • client side application not working as intended while using AsyncSocket

    - by Miraaj
    Hi All, I am using AsyncSocket class in a simple client-server application. As a first step I want that - as soon as connection is established between client and server, client transmit a welcome message - "connected to xyz server" to server and server displays it in textview. //The code in ClientController class is: -(void)awakeFromNib{ NSError *error = nil; if (![connectSocket connectToHost:@"192.168.0.32" onPort:25242 error:&error]) { NSLog(@"Error starting client: %@", error); return; } NSLog(@"xyz chat client started on port %hu",[connectSocket localPort]); } - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port{ [sock writeData:[@"connected to xyz server" dataUsingEncoding:NSUTF8StringEncoding] withTimeout:30.0 tag:0]; } - (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag{ // some relevant code goes here } - (void)onSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag{ NSLog(@"within didWriteDataWithTag:"); // getting this message, means it should have written something to remote socket but // delegate- onSocket:didReadData:withTag: at server side is not getting invoked } // The code in ServerController class is: - (IBAction)startStop:(id)sender{ NSLog(@"startStopAction"); if(!isRunning) { NSError *error = nil; if(![listenSocket acceptOnPort:INPUT_PORT error:&error]) { NSLog(@"Error starting server: %@", error); return; } NSLog(@"Echo server started on port %hu",[listenSocket localPort]); isRunning = YES; [sender setTitle:@"Stop"]; } else { // Stop accepting connections [listenSocket disconnect]; // Stop any client connections int i; for(i = 0; i < [connectedSockets count]; i++) { // Call disconnect on the socket, // which will invoke the onSocketDidDisconnect: method, // which will remove the socket from the list. [[connectedSockets objectAtIndex:i] disconnect]; } NSLog(@"Stopped Echo server"); isRunning = false; [sender setTitle:@"Start"]; } } - (void)onSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket{ [connectedSockets addObject:newSocket]; } - (void)onSocket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port{ NSLog(@"Accepted client %@:%hu", host, port); // it is getting displayed [sock readDataToData:[AsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:0]; } - (void)onSocket:(AsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag{ NSString *msgReceived = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; NSLog(@"msgReceived in didReadData- %@",msgReceived); // it is not getting displayed [outputView insertText:msgReceived]; [sock readDataToData:[AsyncSocket CRLFData] withTimeout:READ_TIMEOUT tag:0]; } Can anyone suggest me where I may be wrong?? Thanks in advance...... Miraaj

    Read the article

  • NSURLConnectionDelegate connection:didReceiveData not working

    - by Shibin Moideen
    Hi All, I need some help regarding the NSURLConnectionDelegate method. - (void)startDownload { NSString *URLString = [NSString stringWithFormat:appRecord.imageURLString]; NSURL *url = [NSURL URLWithString:URLString]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; imageConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if(imageConnection) { activeDownload = [NSMutableData data]; } } I am using this method to initiate the NSURLConnection, but the - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data is not calling.. Need Help Thanks in advance, Shibin

    Read the article

  • iphone application

    - by jaynaiphone
    I am working on the module in which I have to decompress the data. The data comes from server which is zipped using gzip format. I am using NSData+Gzip.m file in which there is a function named "gzipInflate" to unzip the data. but it gives me the error "Z_OK -3". Now what is the solution of that error. How can I solve it. Please reply me :)

    Read the article

  • Getting Data For Webpages?

    - by fuzzygoat
    When looking to get data from a web page whats the recommended method if the page does not provide a structured data feed? Am I right in thinking that its just a case of doing an NSURLRequest and then hacking what you need out of the responseData(NSData*)? I am not too concerned about the implementation in Xcode, I am more curious about actually collecting the data, before I start coding a "hunt & peck" through a list of data. gary

    Read the article

  • iPhone Development: Use POST to submit a form

    - by Mario
    I've got the following html form: <form method="post" action="http://shk.ecomd.de/up.php" enctype="multipart/form-data"> <input type="hidden" name="id" value="12345" /> <input type="file" name="pic" /> <input type="submit" /> </form> And the following iPhone SDK Submit method: - (void)sendfile { UIImage *tempImage = [UIImage imageNamed:@"image.jpg"]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setHTTPMethod:@"POST"]; [request setURL:[NSURL URLWithString:@"http://url..../form.php"]]; NSString *boundary = @"------------0xKhTmLbOuNdArY"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField: @"Content-Type"]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n%@\r\n",boundary] dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[@"Content-Disposition: form-data; name=\"id\"\r\n\r\n" dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[@"12345" dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"\r\n%@\r\n",boundary] dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[@"Content-Disposition: form-data; name=\"pic\"; filename=\"photo.png\"\r\n" dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[NSData dataWithData:UIImageJPEGRepresentation(tempImage, 90)]]; [body appendData:[[NSString stringWithFormat:@"\r\n%@",boundary] dataUsingEncoding:NSASCIIStringEncoding]]; // setting the body of the post to the reqeust [request setHTTPBody:body]; NSError *error; NSURLResponse *response; NSData* result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString* aStr = [[[NSString alloc] initWithData:result encoding:NSASCIIStringEncoding] autorelease]; NSLog(@"Result: %@", aStr); [request release]; } This does not work, but I have no clue why. Can you please help me?!! What am I doing wrong?

    Read the article

  • How to reduce UIImage size to a maximum as possible

    - by Tharindu Madushanka
    I am using following code to resize the image. Resize a UIImage Right Way And I use interpolation quality as kCGInterpolationLow. And then I use UIImageJPEGRepresentation(image,0.0) to get the NSData of that image. Still its a little bit high in size around 100kb. when I send it over the network. Can I reduce it further. If I am to reduce it more what could I do ? Thanks and Kind Regards,

    Read the article

  • Getting exception when coming back while loading data in controller while using LibXml.

    - by user133611
    Hi All, In my project i using LibXml to parse data, when i select a row in first controller i will take to next conttroller where i will get data using libxml if i click on the back button while loading the page i am getting exception. if i click afetr loading is completed it is working fine ca any one help me. the exception is showing here (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // Process the downloaded chunk of data. xmlParseChunk(_xmlParserContext, (const char *)[data bytes], [data length], 0); } Thank You

    Read the article

  • Error while attempting to output data onto console in xcode

    - by Michael Amici
    I am trying to output general data (source code) from a website, but it just sits there. Can't figure out if its the interface or the code. Would someone double-check for me? #import "Lockerz_RedemptionViewController.h" @implementation Lockerz_RedemptionViewController -(IBAction)start: (id) sender { while (1) { NSMutableData *mydata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://ptzplace.lockerz.com/"]]; NSString *output = [[NSString alloc] initWithData:mydata encoding:NSASCIIStringEncoding]; NSLog(output); } }

    Read the article

  • iOS equivalent to MacOS NSAttributedString initWithRTF

    - by trekme
    What is an iOS equivalent to MacOS NSAttributedString initWithRTF ? The Application Kit extends Foundation’s NSAttributedString class by adding support for RTF, RTFD, and HTML (with or without attachments), graphics attributes (including font and ruler attributes), methods for drawing attributed strings, and methods for calculating significant linguistic units. - (id)initWithRTF:(NSData *)rtfData documentAttributes:(NSDictionary **)docAttributes I need to process a short stream of RTF data in an iOS application. Thank you!

    Read the article

  • populate CoreData data model from JSON files prior to app start

    - by johannes_d
    I am creating an iPad App that displays data I got from an API in JSON format. My Core Data model has several entities(Countries, Events, Talks, ...). For each entity I have one .json file that contains all instances of the entity and its attributes as well as its relationships. I would like to populate my Core Data data model with these entities before the start of the App (otherwise it takes about 15 minutes for the iPad to create all the instances of the entities from the several JSON files using factory methods). I am currently importing the data into CoreData like this: -(void)fetchDataIntoDocument:(UIManagedDocument *)document { dispatch_queue_t dataQ = dispatch_queue_create("Data import", NULL); dispatch_async(dataQ, ^{ //Fetching data from application bundle NSURL *tedxgroupsurl = [[NSBundle mainBundle] URLForResource:@"contries" withExtension:@"json"]; NSURL *tedxeventsurl = [[NSBundle mainBundle] URLForResource:@"events" withExtension:@"json"]; //converting the JSON files to NSDictionaries NSError *error = nil; NSDictionary *countries = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:countriesurl] options:kNilOptions error:&error]; countries = [countries objectForKey:@"countries"]; NSDictionary *events = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:eventsurl] options:kNilOptions error:&error]; events = [events objectForKey:@"events"]; //creating entities using factory methods in NSManagedObject Subclasses (Country / Event) [document.managedObjectContext performBlock:^{ NSLog(@"creating countries"); for (NSDictionary *country in countries) { [Country countryWithCountryInfo:country inManagedObjectContext:document.managedObjectContext]; //creating Country entities } NSLog(@"creating events"); for (NSDictionary *event in events) { [Event eventWithEventInfo:event inManagedObjectContext:document.managedObjectContext]; // creating Event entities } NSLog(@"done creating, saving document"); [document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:NULL]; }]; }); dispatch_release(dataQ); } This combines the different JSON files into one UIManagedDocument which i can then perform fetchRequests on to populate tableViews, mapView, etc. I'm looking for a way to create this document outside my application & add it to the mainBundle. Then I could copy it once to the apps DocumentsDirectory and be able I use it (instead of creating the Document within the app from the original JSON files). Any help is appreciated!

    Read the article

  • Changing RGB color image to Grayscale image using Objective C

    - by user567167
    I was developing a application that changes color image to gray image. However, some how the picture comes out wrong. I dont know what is wrong with the code. maybe the parameter that i put in is wrong please help. UIImage *c = [UIImage imageNamed:@"downRed.png"]; CGImageRef cRef = CGImageRetain(c.CGImage); NSData* pixelData = (NSData*) CGDataProviderCopyData(CGImageGetDataProvider(cRef)); size_t w = CGImageGetWidth(cRef); size_t h = CGImageGetHeight(cRef); unsigned char* pixelBytes = (unsigned char *)[pixelData bytes]; unsigned char* greyPixelData = (unsigned char*) malloc(w*h); for (int y = 0; y < h; y++) { for(int x = 0; x < w; x++){ int iter = 4*(w*y+x); int red = pixe lBytes[iter]; int green = pixelBytes[iter+1]; int blue = pixelBytes[iter+2]; greyPixelData[w*y+x] = (unsigned char)(red*0.3 + green*0.59+ blue*0.11); int value = greyPixelData[w*y+x]; } } CFDataRef imgData = CFDataCreate(NULL, greyPixelData, w*h); CGDataProviderRef imgDataProvider = CGDataProviderCreateWithCFData(imgData); size_t width = CGImageGetWidth(cRef); size_t height = CGImageGetHeight(cRef); size_t bitsPerComponent = 8; size_t bitsPerPixel = 8; size_t bytesPerRow = CGImageGetWidth(cRef); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); CGBitmapInfo info = kCGImageAlphaNone; CGFloat *decode = NULL; BOOL shouldInteroplate = NO; CGColorRenderingIntent intent = kCGRenderingIntentDefault; CGDataProviderRelease(imgDataProvider); CGImageRef throughCGImage = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpace, info, imgDataProvider, decode, shouldInteroplate, intent); UIImage* newImage = [UIImage imageWithCGImage:throughCGImage]; CGImageRelease(throughCGImage); newImageView.image = newImage;

    Read the article

  • Error With Sending mail (kSKPSMTPPartMessageKey is nil)

    - by user1553381
    I'm trying to send mail in iPhone using "SKPSMTPMessage" and I added the libraries, In my class I added the following code: - (IBAction)sendMail:(id)sender { // if there are a connection if ([theConnection isEqualToString:@"true"]) { if ([fromEmail.text isEqualToString:@""] || [toEmail.text isEqualToString:@""]) { UIAlertView *warning = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ??? ????? ???? ????????" delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [warning show]; }else { SKPSMTPMessage *test_smtp_message = [[SKPSMTPMessage alloc] init]; test_smtp_message.fromEmail = fromEmail.text; test_smtp_message.toEmail = toEmail.text; test_smtp_message.relayHost = @"smtp.gmail.com"; test_smtp_message.requiresAuth = YES; test_smtp_message.login = @"[email protected]"; test_smtp_message.pass = @"myPass"; test_smtp_message.wantsSecure = YES; NSString *subject= @"Suggest a book for you"; test_smtp_message.subject = [NSString stringWithFormat:@"%@ < %@ > ",fromEmail.text, subject]; test_smtp_message.delegate = self; NSMutableArray *parts_to_send = [NSMutableArray array]; NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys: @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey, [messageBody.text stringByAppendingString:@"\n"], kSKPSMTPPartMessageKey, @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey, nil]; [parts_to_send addObject:plain_text_part]; // to send attachment NSString *image_path = [[NSBundle mainBundle] pathForResource:BookCover ofType:@"jpg"]; NSData *image_data = [NSData dataWithContentsOfFile:image_path]; NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys: @"inline;\r\n\tfilename=\"image.png\"",kSKPSMTPPartContentDispositionKey, @"base64",kSKPSMTPPartContentTransferEncodingKey, @"image/png;\r\n\tname=Success.png;\r\n\tx-unix-mode=0666",kSKPSMTPPartContentTypeKey, [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey, nil]; [parts_to_send addObject:image_part]; test_smtp_message.parts = parts_to_send; Spinner.hidden = NO; [Spinner startAnimating]; ProgressBar.hidden = NO; HighestState = 0; [test_smtp_message send]; } }else { UIAlertView *alertNoconnection = [[UIAlertView alloc] initWithTitle:@"?????" message:@"?? ???? ???? " delegate:self cancelButtonTitle:@"?????" otherButtonTitles:nil, nil]; [alertNoconnection show]; } } but when I tried to send it gives me the following Exception: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString appendString:]: nil argument' and it highlighted this line in SKPSMTPMessage.m [message appendString:[part objectForKey:kSKPSMTPPartMessageKey]]; and I Can't understand what is nil exactly Can Anyone help me in this issue? Thanks in Advance.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >