nsdata

Save a NSArray to iCloud and retrieve it

隐身守侯 提交于 2019-12-25 03:18:24
问题 I have an app that currently saves a NSMutableArray to a file in the documents directory on the iPad. This is saved by [residentData writeToFile:filePath atomically:NO]; and is read back in by; residentData = [[NSMutableArray alloc] initWithContentsOfFile:filePath]; I need to write this file to iCloud, as the data needs to be available across several devices. I have tried the following to create the file in iCloud; NSData *myFileData = [NSKeyedArchiver archivedDataWithRootObject:residentData]

Convert NSData to NSString and ignore null bytes?

让人想犯罪 __ 提交于 2019-12-25 02:50:52
问题 I need to convert a NSData object to an NSString. It is meant to be gibberish but I need it for debbuging. When I use NSString's initWithData, it breaks as the data has NULL bytes. How can I make it ignore the null bytes and get a proper string? 回答1: Copy the NSData to a NSMutableData, byte by byte, skipping any null bytes. Then initialise the string from that. 来源: https://stackoverflow.com/questions/3949628/convert-nsdata-to-nsstring-and-ignore-null-bytes

Generating a DTMF tone doesn't work - application crashes!

坚强是说给别人听的谎言 提交于 2019-12-25 01:32:38
问题 I want to generate a custom DTMF tone and play it on the iPhone. In order to do so, I have created and allocated a memory buffer with a custom tone (ptr). Now I want to create a NSData object, initialized with the memory buffer, and pass it to AVAudioPlayer using initWithData:error: instance method. I wrote the following code, but when I run my application, it crashes. #import "AudioPlayerViewController.h" #include <stdlib.h> #include <math.h> #define SIZE 10 #define LENGTH 65535 const int

MPMoviePlayerViewController play from NSData (MP4)

爷,独闯天下 提交于 2019-12-25 00:21:38
问题 NSString *p = [app getFilePathFor:name]; // Printing description of p: // /Users/Jackson/Library/Application Support/iPhone Simulator/5.0/Applications/7FE97EDD-D080-4E5E-8EDD-3D9FFA8F6CF5/Documents/6681a4d7-8630-4a12-90c6-f95d72650a42 NSData *data = [NSData dataWithContentsOfFile:p]; // Printing description of data: // <01401dc2 a15ebc27 e473ee79 316568ff 19dc7000 df3f7c5c dc206870 01a1c00e 00010000 00000000 00e10288 00000003 01060020 08c80038 00080000 88edffbf 02000119 0000050e 00000000

Apple rejected app due to a crash which is not reproducing

空扰寡人 提交于 2019-12-24 23:25:24
问题 Apple provided the crash logs which explains the encountered exception and reason as below: Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0 Application Specific Information: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFData dataUsingEncoding:]: unrecognized selector sent to instance 0x1b4c20' Here are the lines of code highlighted as the reason of crash after symbolicting the crash logs NSXMLParser

How come I can't successfully load an NSImage from it's full path? Swift 2

情到浓时终转凉″ 提交于 2019-12-24 16:04:41
问题 I'm trying to load an image from an absolute path into an NSImage and even though the same full path works in other scenarios when I'm using it in this context, the variable just ends up being nil . I've tried using both the file path and an NSURL to achieve it. //: Playground - noun: a place where people can play import Cocoa import AppKit print ("Starting") /** Attempt to do via NSURL **/ // The workspace var workspace = NSWorkspace.sharedWorkspace() // Main screen var screen = NSScreen

iPad: ImageIO: <ERROR> JPEGNot a JPEG file: starts with 0xff 0xd9 [closed]

ぐ巨炮叔叔 提交于 2019-12-24 11:07:17
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . the error-message i quoted in question-title is driving me crazy on my iPad. i am downloading some Jpeg-Files form HTTP-Servers, and using my code works

What kind of data does apple use on GLPaint example?

删除回忆录丶 提交于 2019-12-24 10:09:11
问题 Few months ago i made an app based on apple GLPaint. It works great. I have recorded sets of points that draw simple drawings on the screen. and saved them as array of points (converted to NSValue). i am trying to improve my app now and i looked again at apple example. the data in their data file looks like that (i have changed it a little bit): <data> AAC8QgAAsEMAAMJCAICoQwAAwkIBBAKRDAADCQgCAnUMAAMJCAACYQwAAwEIAgJRDAADA QgCAkkMAAMBCAACRQwAAwEIAgJBDAADAQgCAkEM= </data> <data>

Why Data and NSData print differently

落花浮王杯 提交于 2019-12-24 09:40:25
问题 This will, I'm sure, point out my knowledge gap. But I don't seen anything about this in the S.O. knowledge banks and looking at the foundation code has not shed any light for me. Basic question: why does Swift's Data print differently than NSData? e.g. func getData(_ data:Data) { print("The TLV was: \(data as NSData)") } prints: The TLV was: <020101> But ... func getData(_ data:Data) { print("The TLV was: \(data)") } prints: The TLV was: 3 bytes Thanks. 回答1: "Data from Swift 3 has no "built

MonoTouch: How to save a huge PDF downloaded from an URL incrementally?

别等时光非礼了梦想. 提交于 2019-12-24 08:39:11
问题 I need to download a huge PDF file from an URL in my MonoTouch iPhone/iPad newsstand app. The PDF is too big to fit in memory, so I need to save it incrementally with NSData. My idea is the following: instead of appending all the downloaded data in NSData and at the very end of the download, when I got all data, to store it to a file, I want to execute the download asynchronously in a separate thread and append to a file each received chunk and free my memory, but be certain that if the