Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AbhishekApple

macrumors member
Original poster
Aug 5, 2010
86
0
Please suggest for this.....

I am facing a strange problem....
the following code converts data of only one image from the list of images and rest of the images it finds null..
(i checked with the images they are all present on the server )
(I did tested the app on device am facing same issue)

Code:
for (NSString *name in imagesArray){

NSLog(@"%@",name);
NSString *imgPath=[NSString stringWithFormat:@"http://www.abc.com/images/thumbnails/%@",name];
NSData *imageData=[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imgPath]];
NSLog(@"ImageData=%@",imageData);
UIImage *thumbImage = [UIImage imageWithData:imageData];
[imageData release];
.....
.....
....
}

Heres the output i am getting
2010-12-01 17:22:18.867 Image2Pdf[2150:207] 27.jpg
2010-12-01 17:22:18.868 Image2Pdf[2150:207] ImageData=(null)
2010-12-01 17:22:23.954 Image2Pdf[2150:207] 34.jpg
2010-12-01 17:22:23.956 Image2Pdf[2150:207] ImageData=(null)
2010-12-01 17:22:25.283 Image2Pdf[2150:207] 10.jpg
2010-12-01 17:22:25.284 Image2Pdf[2150:207] ImageData=(null)
2010-12-01 17:22:26.321 Image2Pdf[2150:207] 22.jpg
2010-12-01 17:22:26.322 Image2Pdf[2150:207] ImageData=(null)
2010-12-01 17:22:27.202 Image2Pdf[2150:207] 29.jpg
2010-12-01 17:22:31.121 Image2Pdf[2150:207] ImageData=<ffd8ffe0 00104a46 49460001 02000064 00640000 ffec0011 4475636b 79000100 04000000 3c0000ff ee000e41 646f6265 0064c000 000001ff db008400 06040404 05040605 05060906 0506090b 08060608 0b0c0a0a 0b0a0a0c 100c0c0c 0c0c0c10 0c0e0f10 0f0e0c13 13141413 131c1b1b 1b1c1f1f 1f1f1f1f 1f1f1f1f 01070707 0d0c0d18 1010181a 1511151a 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1f1f1f1f 1fffc000 110800b4 00b40301 11000211 01031101 ffc400a3 00010002 03010101 00000000 00000000 00000304 02050706 08010101 00020301 01000000 00000000 00000000 02030104 05060710 00020201 02030405 060b0803 00000000 00010203 04110521 12063141 22075161 71b11381 91a13272 14c1d142 82a22333 5363b344 f0e162b2 c2d21508 73931711 01000201 02040307 03050100 00000000 00010211 03042141 12053151 61718191 a1421306 b1d1e1f0 c1223252 43ffda00 0c030100 02110311 003f00fa a4000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 142fea0d 871e7285 fb8e2d53 83d2509d d5c5a6bb 9a6c84ea d63c6617 d76dab68 cc56d3ee 953b7ae3 a3eafafb c6270f45 b17ee6ca e773a71f 542eaf6d dc4f869d be0a96f9 95d0d5fd 6dde97f6 54e5fe58 b233bcd2 ff00a5d1 d9b773ff 009caa5d e6e74257 fd7ca7f6 69b5fbe2 884efb4b cd757b06 ee7e8f9c 2a4fceae 898fd59e 4d9f66af f734467b 8e97afc1 6c7e37bb 9e55f8a4 da7cdee9 8dcf73a3 02aaf22a 9e4cd555 5b6c22a1 cf2e114f 4937c599 d3dfd2d6 888cf147 73d8371a 18f8245b 76325fb3 5f2b7f8c 9f4c23d5 2cfee38d fbb8fb34 338863aa 5343071f 4e108af9 11988426 f29a1890 8f64568b d090c31d 68f70ae7 1a237d2f 96dc792b 2125da9a 7dbf3f13 2aef1168 989f097d 09d37bbd 7bc6c583 b943fa9a a339a5dd 3ec9af92 49a3bda5 7eaac4be 67bad09d 2d4b5279 4b6458a0 00000000 00000000 00000000 68bae33f 130ba577 1bb2e374 9cab8455 92ad4571 e46b8fb7 81c797be cb186029 3f15b73f cffee318 666d2b70 daf15e9c dcefdb39 7e327158 53379588 6d5b7f7d 29fb5c9f bd928885 537b79a6 86d9b72f e9e1f2ad 7de66221 09bcac55 878b5f8a baa3197a 63149fd0 4b1084da 52f4eee3 ff0007d6 fb76737c b8d94fee d92fbb96 cf0eafd8 f9596685 fa35225a 3dd343ef 6ded1ce3 8c7b9dec ed3c0800 00000000 00000000 000000e4 de71e766 4b3b1705 430adc2e 54e4e5f0 e7975d8e 5aeb14df c4845c52 e2968fbc e5f70b4e 623863e6 f61f8ce9 00000000 00000000 00000000 00000000 00000000 000fffd9>


And some times i am getting this error,,,,,,
> Assertion failed: (cls), function getName, file
> /SourceCache/objc4_Sim/objc4-427.1.1/runtime/objc-runtime-new.m, line 3939
 
I'm not sure why it's not working, but you shouldn't be downloading like this as it's a synchronous process and cannot be canceled. Instead use NSURLConnection and download asynchronously.
 
You sure about that?

I checked your first image, based on your code and output. http://www.abc.com/images/thumbnails/27.jpg gets redirected to http://abc.go.com/images/thumbnails/27.jpg and then comes back with a "sorry, we couldn't find that page" message.

I think "abc.com" was used as a fake name. The OP should have used "example.com".


Just because a file is on a server doesn't mean it's accessible to HTTP requests.

A simple test is to paste the complete URL of the image into the address bar of any browser, and see if it can retrieve the image from the server. If a browser can retrieve it, then the iphone app should be able to retrieve it, too. There's no magic here: it's just an HTTP request and reply. If you get 404 Not found responses (or 3xx redirects, or anything other than a 200 OK), then you need to fix something outside of the iphone app.

A better test is to watch what's actually happening on the network when the iphone program runs. Tools that do this are called "traffic watchers" or "packet sniffers". One such tool is WireShark:
http://www.wireshark.org/download.html

Interarchy 8 also had traffic watching ability, but it's gone from recent Interarchy versions.
 
I think "abc.com" was used as a fake name. The OP should have used "example.com".


Just because a file is on a server doesn't mean it's accessible to HTTP requests.

A simple test is to paste the complete URL of the image into the address bar of any browser, and see if it can retrieve the image from the server. If a browser can retrieve it, then the iphone app should be able to retrieve it, too. There's no magic here: it's just an HTTP request and reply. If you get 404 Not found responses (or 3xx redirects, or anything other than a 200 OK), then you need to fix something outside of the iphone app.

A better test is to watch what's actually happening on the network when the iphone program runs. Tools that do this are called "traffic watchers" or "packet sniffers". One such tool is WireShark:
http://www.wireshark.org/download.html

Interarchy 8 also had traffic watching ability, but it's gone from recent Interarchy versions.

(abc.com is jst an example)
And yes the actual url didn't retrieved the images as the "name" which i was retrieving had a leading space because of which it was getting null
like http://www.example.com/images/ 10.jpg

Same old problem
Thanks a lot for reminding
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.