Thanks Esteban and Wim,

Indeed, using javascript or jQuery can also be an option.

What actually speeds things up significantly is to revert back to NSString and 
use NSRegularExpression.

I now needs seven seconds on iPad3 to handle >600 replacement actions. This is, 
in itself a VERY long time, but since it is handled by an async task and we 
notify the user that for large law documents this action may take a few 
seconds, the UX should be acceptable, hopefully (up to test group to decide).

Additionally, I can show a progress bar to give visual feedback.

Moreover, less than 5% of the laws included in the app are that large. Most 
laws are handled and updated within two seconds.

Thanks again for thinking with me, I hugely appreciate it.



Best regards,

Diederik



Op Aug 22, 2013, om 1:57 AM heeft Wim Lewis <w...@omnigroup.com> het volgende 
geschreven:

> 
> On 21 Aug 2013, at 4:44 PM, Diederik Meijer | Ten Horses wrote:
>> The web service returns the list lightning fast, but in order to get the 
>> count number added to each of the >300 articles html <h4> header, I am 
>> looping through the list and call NSString's 
>> stringByReplacingOccurancesOfString:withString: on each item.
>> 
>> There must be a more efficient way to update the html string loaded from the 
>> local file, obviously doing more than 300 of these replace actions is slow 
>> and inefficient.
> 
> The -stringByReplacing... method has to copy the entire string each time you 
> do a replacement. You might be able to get a significant speedup making a 
> mutable copy of the original string, calling 
> -replaceOccurrencesOfString:withString: repeatedly, and (possibly) calling 
> -copy to make a final immutable copy.
> 
> Depending on what you're doing, though, it might make more sense to load the 
> original string into the WebView and manipulate the WebView's DOM to update 
> all of the counts and things.
> 
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/diederik%40tenhorses.com
> 
> This email sent to diede...@tenhorses.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to