nsmutabledata

Objective-c/IOS: Reversing the bytes in NSMutabledata

醉酒当歌 提交于 2020-01-04 07:26:43
问题 In my application I have the bytes of an audio file stored in NSMutableData like so: NSMutableData *data = [NSMutableData dataWithBytes:byteData length:len]; I can then later play this using player = [[AVAudioPlayer alloc] initWithData:data error:&error]; My question is what code would reverse the bytes in the data object, so that when played the sound is backwards? Any help is very much appreciated. By the way, the byteData of the audio is obtained using: NSMutableData *wave =[NSMutableData

NSURLConnection crash on releasing NSMutableData

送分小仙女□ 提交于 2019-12-24 08:58:19
问题 I have followed the instruction from Using NSURLConnection and sometimes (very very seldom) my project crashes in method. - (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [connection release]; [myNSMutableData release]; } It crashes when i try to release my NSMutableData . I want to know why it crashes! Some code I use: - (void) start { while (1) { NSString *stringURL = @"http://www.iwheelbuy.com/get.php?sex=1"; NSURL *url = [NSURL URLWithString:stringURL]

Difference between NSMutableData's mutableBytes and bytes methods

耗尽温柔 提交于 2019-12-24 02:25:09
问题 Both return the same pointer. I know - bytes belongs to NSData , why does NSMutableData introduce - mutableBytes ? Is it just for code clarity so it is more obvious you are accessing mutable data? Does it really matter which one is used? NSMutableData* mydata = [[NSMutableData alloc] init]; [mydata appendData: [@"hello" dataUsingEncoding:NSUTF8StringEncoding]]; NSLog(@"%p", [mydata mutableBytes]); NSLog(@"%p", [mydata bytes]); Thanks. 回答1: There are a couple of reasons why NSMutableData might

problems with NSMutabledata byteswithnocopy [duplicate]

心已入冬 提交于 2019-12-23 18:28:15
问题 This question already has an answer here : NSMutableData datawithBytesNoCopy:length:freeWhenDone: seems to make a copy of the buffer provided to it (1 answer) Closed 5 years ago . I am trying to write a code to create NSMutableData from malloced buffer.I used freewhendone = YES 1) It gives an error in accessing the buffer after NSData is created.(in memset in below code) 2) The malloced buffer pointer and [data bytes] pointer are different. Is there any explanation for these? UWORD8 *rgb

How to convert bytes to a float value in swift?

纵饮孤独 提交于 2019-12-18 05:06:18
问题 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 }

Convert string to mutable data - objective c [duplicate]

∥☆過路亽.° 提交于 2019-12-14 04:14:06
问题 This question already has answers here : objective-c: how to assign string to NSMutableData? (4 answers) Closed 3 years ago . How to convert a string into mutable data in objective c 回答1: You can do something like, NSString *str = @"any string"; NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; NSMutableData *mutableData = [data mutableCopy];; Hope this will help :) 回答2: You can convert NSString to NSData by using NSString* str = @"mystring"; NSData* data = [str dataUsingEncoding

Converting INT to Hex string to be sent over BLE

会有一股神秘感。 提交于 2019-12-11 19:57:45
问题 I am trying to convert several 'int' values to hex so that they can sent over bluetooth as a command. I have tried numerous things, but while I get the same result with different methods, I cannot get the desired result to send over BLE so that the device recognizes the command. - (void)sendValues:(int)value1 value2:(int)value2 value3:(int)value3 value4:(int)value4 { // value1 = 734, // value2 = 43 // value3 = 50 // value4 = 7 // this string should be constructed from the values passed

Key-Value Observing with NSMutableData iOS

我是研究僧i 提交于 2019-12-11 19:17:35
问题 In my model I have NSMutableData Object called data. I want to observe it from another object and get a notification when data is added or removed. I understand that this is a to-many relationship, so I can't use the normal KVO by first adding the observer with this code [object addObserver:self forKeyPath:@"data" options:NSKeyValueObservingOptionNew context:NULL]; and then implement the observeValueForKeyPath:ofObject:change:context: method to do something when the notification is send. I

NSMutableData response string

戏子无情 提交于 2019-12-11 04:35:44
问题 I am trying to upload images to yFrog which is working just fine, but I want to grab just the URL from the response. When I use the NSURLConnection method - (void) connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString* responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding]; // NSString *url = [webData valueForKey:@"mediaurl"]; NSLog(@"result: %@", responseString); } I get this as my response string result: <?xml version="1.0"

NSMutableData error

心不动则不痛 提交于 2019-12-11 04:27:09
问题 Let me start to say that I'm new to iOS/Xcode programming so I don't know even what to ask exactly. I'm trying to add a static library to an app and I'm ending up with a crash. The library package has a .h file and a .a file. I'm asking for some suggestions about how to proceed to figure out the problem. Here some facts : Xcode 7.3 - El captain OS the library is working. I have a demo app that is working with no crash using the same library I'm trying to use I didn't find significative