objective c - App crashed with message "terminated due to memory error" -


I have a function that converts my array into a string when I use this function for an array of 50000 length I run, my app crashes and the message ends with memory error, here my function is given below.

  - (NSString *) getStringFromArray: (NSMutableArray *) array {NSString * resultantString = [array ObjectAntEndex: 0]; For (int i = 1; i & lt; [aree count]; i ++) {result string {[nsstring stringwat format: @ "% @% @", resulting string, [array objectattendex: I]]; } Return result string; }  

You can try to use multiples NSString instead, so end

Something like this:

  - (NSString *) getStringFromArray: (NSMutableArray *) array {// NSString * resultantString = [Orke object import index: 0]; NSMutableString * buffer = [[NSMutableString alloc] init]; (For example, i.e., i, lt; [arl count]; i ++) {// result string = [nsstring string with format: @ "% @% @", resulting string, [array objectattinedx: i] ]; [Buffer ependrosting: [array objectattex: i]]; } NSString * resultantString = [[buffer copy] AutoCare]; Return result string; }  

The code was not checked, because I'm not in Mac to do this, but this is the idea

Hope this helps


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -