On 21 Sep 2014, at 6:08, 2551 wrote:

As I've been saying all along, this is such a common operation, I'd have thought there must be a common cocoa method or API for doing it. So the question is, can anyone tell me what that is?

The general problem you’re dealing with is that of finding the longest common subsequence. This is a difficult problem so it is often solved with heuristics. Wikipedia: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem

One solution is the UNIX diff command <x-man-page://1/diff> which, as Jens previously mentioned, works on lines and is commonly used by version control systems and programmers. You can call out to this command from Cocoa (e.g. via NSTask).

You can read about the implementation here http://www.xmailserver.org/diff2.pdf

An attempt of improving the quality of this command (for source code diff’ing) exists: http://alfedenzo.livejournal.com/170301.html

If you need a C API then have a look at https://code.google.com/p/google-diff-match-patch/
_______________________________________________

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