Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-19-2010, 06:32 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 2
lolcott is on a distinguished road
Default Issue using Variables to load PDF File in iphone SDK

Hi all, I'm trying to load a PDF in my App:

Using this works fine

Code:
    pdfURL=[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: @"myFile" ofType:@"pdf"]];

            controller.pdfUrl = pdfURL;
            [self.navigationController pushViewController:controller animated:YES];
            [controller release];
However, i would like to be able to call the file from a NSString variable. i.e. Take out the @"myFile" and insert NSString fileName. Any idea what i'm doing wrong?

Thanks in advance!
lolcott is offline   Reply With Quote
Old 07-19-2010, 06:54 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Boston, MA
Posts: 135
carbonbasednerd is on a distinguished road
Default

Should be able to do it. I assume because the code you sent works that you have a file named 'myFile.pdf' so if you you want to get a new file you should just put in the new file name and it should work providing the file is known to the project.
carbonbasednerd is offline   Reply With Quote
Old 07-19-2010, 07:06 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 2
lolcott is on a distinguished road
Default

Quote:
Originally Posted by carbonbasednerd View Post
Should be able to do it. I assume because the code you sent works that you have a file named 'myFile.pdf' so if you you want to get a new file you should just put in the new file name and it should work providing the file is known to the project.
new code code is
Code:
 pdfURL=[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: fileName ofType:@"pdf"]];
And i get a: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSURL initFileURLWithPath:]: nil string parameter' error in console.

I put a NSLog right before to check for an empty fileName. It is not empty. Thank you for taking a look! -L
lolcott is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, nsstring, pathforresource, pdf

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 327
14 members and 313 guests
akphyo, alexP, appservice, bignoggins, EXOPTENDAELAX, flamingliquid, guusleijsten, Hamad, mariano_donati, ohmniac, Paul Slocum, Rudy, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:42 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0