nsmutabledata

Crashes while fetching data from filepath

这一生的挚爱 提交于 2019-12-10 12:12:10
问题 The app crashes while trying to fetch data from path/URL (video file stored in documents folder) only for large files (>100 MB). Device Details: iOS (4.3), iPad 1 URL is perfect (Checked logs) File exists at that path (checked path) Note: Crashes on device only. Below is the code where app crashes: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); if ([paths count] > 0) { filePath = [paths objectAtIndex:0]; filePath = [filePath

iOS swift NSMutableData has no member appendString

自作多情 提交于 2019-12-06 21:50:53
问题 Hello I am new to swift and I am following a tutorial and creating the same code in order to Upload an image . I am now using swift 3 and it seems like NSMutableData() no longer has the appendString method available what can I do as a substitute ? The tutorial I am following is here http://swiftdeveloperblog.com/image-upload-example/ and my code is this func createBodyWithParameters(parameters: [String: String]?, filePathKey: String?, imageDataKey: NSData, boundary: String) -> NSData { let

NSMutableData remove bytes?

冷暖自知 提交于 2019-12-04 08:52:55
问题 I can add bytes to a NSMutableData instance easily by using the appendData method, however I do not see any similar method for removing data? Am I overlooking something, or do I need to create a new object and copy over only the bytes I need? 回答1: Please see the documentation of the following method: - (void)replaceBytesInRange:(NSRange)range withBytes:(const void *)replacementBytes length:(NSUInteger)replacementLength Apple clearly says the following: If the length of range is not equal to

NSMutableData disappearing

半城伤御伤魂 提交于 2019-12-04 06:49:40
问题 in my Program, I have a NSMutableData variable that collect the information from http://www.nhara.org/scored_races-2013.htm. After about the third time it gets information from a website, when it contains 90810 bytes, it either disappears or becomes null because if I print it a NSString, it is null. Here is the code - (void)viewWillAppear:(BOOL)animated { // Create a new data container for the stuff that comes back from the service xmlData = [[NSMutableData alloc] initWithCapacity:180000];

NSMutableData remove bytes?

故事扮演 提交于 2019-12-03 01:15:41
I can add bytes to a NSMutableData instance easily by using the appendData method, however I do not see any similar method for removing data? Am I overlooking something, or do I need to create a new object and copy over only the bytes I need? Please see the documentation of the following method: - (void)replaceBytesInRange:(NSRange)range withBytes:(const void *)replacementBytes length:(NSUInteger)replacementLength Apple clearly says the following: If the length of range is not equal to replacementLength, the receiver is resized to accommodate the new bytes. Any bytes past range in the receiver

Purge the contents of a data container in real time

冷暖自知 提交于 2019-12-02 10:31:07
My problem is best explained by the architecture below Basically, I have to purge the contents of an NSMutableData object (or any other object, for that matter) in real time, i.e., I can't block its containing thread. Is there a way/API to do this? update: As mentioned in the comments below.. i'm receiving audio packets in real time to the main thread and immediately route it to a dedicated audio pool thread.. (the reason why i got so many threads is b/c i have no control over the reception of the incoming packets.. they come in real time + the rate of playback is a lot slower than the rate of

How to convert bytes to a float value in swift?

浪子不回头ぞ 提交于 2019-11-29 07:14:56
This is my code to convert byte data to float. I tried every answers given in this site. I am getting exponential value for this "<44fa0000>" byte data static func returnFloatValue(mutableData:NSMutableData)->Float { let qtyRange = mutableData.subdataWithRange(NSMakeRange(0, 4)) let qtyString = String(qtyRange) let qtyTrimString = qtyString.stringByTrimmingCharactersInSet(NSCharacterSet(charactersInString: "<>")) let qtyValue = Float(strtoul(qtyTrimString, nil, 16)/10) return qtyValue } Thanks <44fa0000> is the big-endian memory representation of the binary floating point number 2000.0 . To