How to transform NSData back into the original file? [duplicate] - cocoa

This question already has answers here:
How to upload and store files in Cocoa with Core Data?
(3 answers)
Closed 8 years ago.
I am creating a custom NSValueTransformer subclass to save a file as a Transformable attribute in Core Data. I am using [NSData dataWithContentsOfURL:value]; to transform one way, but how do I get the file back?
This is an arbitrary file, so how can I determine what kind it is so I can display the images or open it with a proper application?
Thanks
Chet

Save the URL and/or mime type as we'll so you can examine it (the extension) later to decide what to do.

Related

Xcode Simulator scale [duplicate]

This question already has answers here:
How to resize the iPhone/iPad Simulator?
(12 answers)
Closed 4 years ago.
I am trying to change Simulator scale to 40%. I found that it can be changed using - defaults write ~/Library/Preferences/com.apple.iphonesimulator SimulatorWindowLastScale "0.4"
I modified plist file, tried adding this key with with 0.4 value, also modified SimulatorWindowLastScale-com.apple.CoreSimulator.SimDeviceType.iPhone-6 to 0.4, but I cant seem to get 40% scale.
Has anyone tried this recently.
thanks.
I know about existing thread, thanks anyways.
Looks like attribute has changed, this works -
~/Library/Preferences/com.apple.iphonesimulator SimulatorWindowLastScale-com.apple.CoreSimulator.SimDeviceType.iPhone-6 "0.4"

SIMPLE PIE - Get Images in a particular rss feed [duplicate]

This question already has answers here:
Can SimplePie grab images from feeds
(2 answers)
Closed 9 years ago.
I am trying this feed http://servicios.elpais.com.uy/formatos/rss/index.asp?seccion=ultmom
throw the simplepie demo page and it works great.
I can get a lot of info of this feed, but I dont know how to get the images and if you try the demo it is possible.
How can I get this images?
PS: I dont mean the feed image, I mean each news image
really thanks
Some versions of RSS/Atom have a thumbnail others don't. If you want to get images all images from a feed you'll need to use something like simple_html_dom.
This question gets asked all the time, someone who knows how StackOverflow and SimplePie work should merge these answers.

Making a large quiz for iOS - 100+ Questions (using a .txt file or other)

I am trying to create a quiz app for iOS with 100+ questions. However, I do not want to have to design the UI by hand putting in all the values with the storyboard. I am trying to have pull values from a .txt file and use that to input values in labels and buttons. I need help doing this! I don't know how to have the compiler repeat the action of extracting the question numbers, questions, and answers that are all packed together in this .txt file and input those in the different objects every time you launch the game.
Am I being too unspecific?
Any help is appreciated!
Read the text file into an NSString. Have the data in the text file separated by commas. Use NSString's '-componentsSeparatedByString:' method (passing #"," as argument) to split all questions into an NSArray.

displaying waveform in xcode [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
rendering a waveform on an iphone
Efficient method to draw a line with millions of points
Can anyone please help me with displaying the waveform of an audio file in xcode?
Actually, I've recorded an audio through AVAudioRecorder class. Now, I want to get the waveform of this either while the audio is being recorded OR use the .caf file it saved.
Please?
Thanks :)

Storing an NSImage in a Core Data Model

What is the correct way to store an NSImage in a Core Data Model? I have assumed adding an Attribute to an Entity and giving it the Type "Binary" should work, but it is not working. I have a table with a column of NSImageCells and it is not showing anything.
If you can work in 10.5+, the easiest way is to store the NSImageReps for the image in "Transformable" attribute. By default, the transformable attributes use NSCoding to archive their values on set and unarchive on access. This saves you from having to write custom getters/setters. If you want to get fancy, you could write a custom NSValueTransformer that converts an image to an acrhived version of its representations and visa versa on get. If you're using 10.4, then you have to write custom getters/setters (see Apple's docs on creating Non-standard persistent attributes. You can get the image's image reps by sending the NSImage a -representations message.
If you want to display the images in a UI via bindings, you should also read the Displaying Images Using Bindings section of the Cocoa Bindings Programming Topics.
This doesn't answer the exact question you asked, but depending on how many images you are storing it can be more efficient to store only paths or URLs to the images, saved in your own location, and load them as required.
You'll need to create an NSData representation of it.
Have a look at Non-Standard Persistent Attributes. Especially the section under Transformable Attributes, and Custom Code if that doesn't sort you out.
Here is a really easy implementation
http://objectivesheep.com/blog/nsimage_coredata/

Resources