Questions tagged [writetofile]

for questions concerning the writeToFile method, part of the NSData class in OS X and iOS

This tag should be used for questions that relate to the use of one or more of the various writeToFile methods, which are provided by the NSData class in both the Mac OS X and iOS APIs.

The Apple developer documentation for the NSData class is available online here.

370 questions
2
votes
2 answers

Creating separate files

I am looking for a way to create separate files. For example: I have an application which has a form such as name, date etc. and when I press save, I want to save all the information in that form of the user into a file. Each time the form is filled…
Aneesa
  • 123
  • 3
  • 10
2
votes
1 answer

Objective c save image to gallery

I manipulated some pixels in image and now when i open the image in app, a message appears but problem is that i saved it to my document directory. I want to allow someone to share this photo. If i save the image below, the image data changes.…
user3800960
2
votes
1 answer

Why can't I use write(toFile: ) property on a string?

I'm following a tutorial that was written in some earlier version of Swift, that teaches me how to read/write a .txt file in Swift3. Xcode has been doing a good job so far of letting me know when I'm using old syntax, and changing it for me to the…
Theodore.K
  • 384
  • 2
  • 7
  • 21
2
votes
1 answer

Using Xcode 7/Swift 2 writeToPath to Resources file the call does not fail but no data is written

I am using Xcode 7.3.1 and Swift 2.0. I am using the following code sample: func writeToResourcesDataDir() { if let path = NSBundle.mainBundle().pathForResource("TestData", ofType: ".json") { let str = "Test String" do { …
D Stallmo
  • 31
  • 5
2
votes
1 answer

Write Image To File in Directory

I am getting an error when writing an image file to a directory in Xcode. The function data.writeToFile is returning an error. Here is what I am trying to do: Get The File Path: func getPath(fileName: String) -> String { let documentURL =…
hockeybro
  • 981
  • 1
  • 13
  • 41
2
votes
2 answers

How to insert labels on top of images saved to .WriteToFile in PNG's Swift

I'm trying to save a label on top of an image using .WriteToFile . Here's the code I'm using to save the image : let selectedImage: UIImage = image.image! let fileManager = NSFileManager.defaultManager() let paths =…
Niall Kehoe
  • 379
  • 2
  • 5
  • 18
2
votes
2 answers

Java/JSP: Preserve line breaks while writing to a local file from string variables

I need help to create read-write methods that write to a file and preserve the line breaks. The contents of the file are stored in a variable. I use the following code to read a local HTML file: public String scanLocalPage(String filePath) throws…
user1492667
  • 139
  • 3
  • 13
2
votes
3 answers

Trying to write a dictionary from file, key becomes value

I have an assessment where I have to write a full name with a score to a file, then read it back and be able to sort by either name or high score. I've worked out how to read the file into a dictionary using: d = {} with open("Dr Welch.txt") as f: …
Dave W
  • 21
  • 2
2
votes
1 answer

R write mpfr data (Rmpfr)

I'm have a mpfrArray in R that I am trying to write to file but I get the error message: Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class "structure("mpfr1", package = "Rmpfr")" to a data.frame How would I go about…
Plinth
  • 289
  • 1
  • 13
2
votes
1 answer

NSData writeToFile method returns true but file is not written to the disk

I have developed an OS X app and I sometimes need to save some pictures to the disk. I have a method to do that : func saveImageAtPath(image: NSImage, path: String) { if let data = image.TIFFRepresentation { let bitmap =…
Randy
  • 4,335
  • 3
  • 30
  • 64
2
votes
3 answers

Save files locally in objective C / ios

In the app I'm currently developing i have run into a problem. I have several .plist files that store information. When the app starts it checks one of the plist files (that is empty from the beginning) if it is empty, and if it is it will go to a…
Pointblaster
  • 504
  • 3
  • 18
2
votes
1 answer

writeAsCSV() and writeAsText() is unexpected

I am using apache flink via the Scala API and at some point I obtain a DataSet[(Int, Int, Int)]. The result of using the methods writeAsCSV() and writeAsText() is unexpected. It creates a directory. That directory has as location and name the…
2
votes
2 answers

C# Exception - File cannot be accessed because it is being used by another process

I have a Windows Forms Application that uses 2 forms, with both writing to separate files (file paths given by inclusion of strings in textboxes on the form). For form1, I have a number of functions that write data to the file on various different…
marcuthh
  • 592
  • 3
  • 16
  • 42
2
votes
1 answer

ios - writetofile automatically is not working

I made UMsgs.plist file like this and call below method -(void) checkIsChangedUMsg { BOOL isNewMsg = NO; NSString *destPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; destPath =…
석진영
  • 243
  • 4
  • 13
2
votes
1 answer

Append DataVizualisation Chart Control to text file

I'm developing a system that takes data input from textboxes, and on a button click, saves these values to the respective listbox ready to be written to a text file once the process is complete. The next stage has been using this data to create…
marcuthh
  • 592
  • 3
  • 16
  • 42