Questions tagged [initwithcontentsoffile]
20 questions
30
votes
3 answers
Appending a new line in a file(log file) in c++
I have a logging functionality and in this I have got log files. Now every time I run the program I want that previously written file should not get deleted and should be appended with the current data (what ever is there in the log file)
Just to…

gandhigcpp
- 587
- 3
- 8
- 16
12
votes
1 answer
UIImage initWithContentsOfFile doesn't work
I have question: I want to avoid [UIImage imageNamed:].
So i did:
UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:@"myimage.png"];
controller.productImg.image = prodImg;
[prodImg release];
But now the image is not shown anymore.
Does…

Tanner
- 133
- 1
- 2
- 5
4
votes
1 answer
Getting Error Domain=NSCocoaErrorDomain Code=261 with simple case
I have the following bit of code. path is a bundle path to a file in my bundle.
_dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
NSError *error;
NSString *string = [[NSString alloc] initWithContentsOfFile:path…

Kudit
- 4,212
- 2
- 26
- 32
1
vote
1 answer
initWithContentsOfFile:encoding:error: - NSInvalidArgumentException
I think I am missing something very basic here, but here it goes.
The inline help in XCode tells me that initWithContentsOfFile: deprecated
NSMutableDictionary *myDict = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
Instead…

Kermit
- 2,865
- 3
- 30
- 53
1
vote
1 answer
grabbing data from an internal file
I'm grabbing data from an external file using NSURL with the code below. If i wanted to grab this data from an internal file in my resources folder how would the code be different.
here's the NSURL code:
NSURL *dataUrl = [NSURL…

hanumanDev
- 6,592
- 11
- 82
- 146
1
vote
1 answer
Bad Access Error in setValue method for a NSMutableDictionary created with initWithContentsOfFile iOS Objective C
I have problems with following Objective C Code:
To read a configuration plist for my App I created load and a save Config methods, but after loading a plist correctly into a (newly allocated) NSMutableDictionary I can't change any of the serialized…

aqm
- 142
- 2
- 17
1
vote
2 answers
iOS , Is it possible to read objective C code from a file and execute it at a specific point in the program?
I have a bunch of drawing code (primitive drawing, mostly bezier path drawing calls) thats stored in a couple of files and the draw code runs to about a few hundred lines. I wanted to know if its possible to read this code from a file and execute it…

Sagar
- 555
- 9
- 24
0
votes
1 answer
initWithContentsOfFile reads file in wrong order
I am reading a plist file using code below.
My problem is that the file seems to be read in some random order.
The order is always the same (d,b,e,c,a,f).
Is it possible to read the file in the "correct" order, as entered in file?
prefs.plist file…

Kermit
- 2,865
- 3
- 30
- 53
0
votes
3 answers
mem allocation with imageNamed
I want to display some images, when image is not available I want to show a default one.
When using the analyze functionality I get warnings about a potential leak.
I do under stand that when using imageNamed there is no memory allocated, what would…

ErikS
- 31
- 1
- 5
0
votes
3 answers
Creating NSMutableArray from xml file
I have an xml file with the following information.
-
-
Butch
1
Fighter
-
Shadow
2
Rogue
…

John Lilley
- 159
- 1
- 3
- 13
0
votes
1 answer
Plist file exists in docs dir, but cannot be loaded into an array
The plist has the file suffix .xml and is a normal array of dictionaries.
In the app delegate:
#define docDir [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
-(NSString *)cacheFile:(NSString…

Henrik Erlandsson
- 3,797
- 5
- 43
- 63
0
votes
1 answer
Importing text files into an iOS App
I noticed that when saving a file from within an iOS App using:
writeToFile:myFile atomically:YES
the resulting file is actually saved in XML format, and always has the following code:

sirab333
- 3,662
- 8
- 41
- 54
0
votes
1 answer
NSImage property always return null?
I have a custom class called movie. It is simple with three properties:
.h
@interface WTAMovie : NSObject
@property (strong, nonatomic) NSImage *theImage;
@property (strong, nonatomic) NSString *theTittle;
@property (strong, nonatomic) NSString…

Tommy Alexander
- 701
- 1
- 7
- 17
0
votes
1 answer
Discrepancies between debug/release profiles when counting items from a plist for numberOfItemsInSection for UICollectionView
I have a UICollectionView whose collectionView:numberOfItemsInSection: is defined as follows:
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.contents.count;
}
self.contents…

kid_x
- 1,415
- 1
- 11
- 31
0
votes
3 answers
How to access a json file locally from within the app
I'm trying to figure out how to access a json file locally, from within the app. Currently I've been using the json file remotely from a server like this:
jsonStringCategory = @"http://****categories?country=us";
}
// Download the JSON…

hanumanDev
- 6,592
- 11
- 82
- 146