Note that there are some explanatory texts on larger screens.

plurals
  1. POJson and Bundle resource Xcode
    primarykey
    data
    text
    <p>I can access and display a file from the Xcode bundle like this:</p> <pre><code>NSString *file = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"pdf"]; </code></pre> <p>Now what I want to do is fill in the names of the file using this JSON which does fetch me the correct name:</p> <pre><code>self.localFileName = [BT_strings getJsonPropertyValue:self.screenData.jsonVars:@"localFileName":@""]; </code></pre> <p>How do I put these two thing together so I can call the Bundled file using the JSON name?</p> <p>Here is the whole thing:</p> <pre><code>// // ReaderDemoController.m // PDFViewer // // Created by C. A. Beninati on 5/21/12. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // //BT imports #import &lt;UIKit/UIKit.h&gt; #import &lt;Foundation/Foundation.h&gt; #import &lt;MediaPlayer/MediaPlayer.h&gt; #import "JSON.h" #import "BT_strings.h" #import "testapp_appDelegate.h" #import "BT_fileManager.h" #import "BT_color.h" #import "BT_viewUtilities.h" #import "BT_downloader.h" #import "BT_item.h" #import "BT_debugger.h" #import "BT_viewControllerManager.h" #import "ReaderDemoController.h" #import "ReaderViewController.h" @interface ReaderDemoController ()&lt;ReaderViewControllerDelegate&gt; @end @implementation ReaderDemoController @synthesize localFileName; - (void)viewDidLoad { [BT_debugger showIt:self:@"ZZZZZZZZZZ!!!"]; [super viewDidLoad]; self.localFileName = [BT_strings getJsonPropertyValue:self.screenData.jsonVars:@"localFileName":@""]; self.localFileName = @""; // added this to make it work!! NSString *file=[[NSBundle mainBundle]pathForResource:self.localFileName ofType:@"pdf"]; ReaderDocument *document = [ReaderDocument withDocumentFilePath:file password:nil]; if (document != nil) { ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document]; readerViewController.delegate = self; readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; readerViewController.modalPresentationStyle = UIModalPresentationFullScreen; [self presentModalViewController:readerViewController animated:YES]; } } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } - (void)dismissReaderViewController:(ReaderViewController *)viewController { [self dismissModalViewControllerAnimated:YES]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload