Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (NSComparator)^(id a, id b) {
  2.     // check if user a or user b has unread message
  3.     if( [(UserInfo*)a unreadMsg] > 0 && [(UserInfo*)b unreadMsg] <= 0 ) {   // a has but b
  4.         return a;
  5.     }
  6.     else if [(UserInfo*)a unreadMsg] <= 0 && [(UserInfo*)b unreadMsg] > 0 ) {   // b has but a
  7.         return b;
  8.     }
  9.     else {  // both have unread msg or neither has unread msg
  10.         // then check distance
  11.         if ([(UserInfo*)a distance] < [(UserInfo*)b distance]) {
  12.             return a;
  13.         }
  14.         else {
  15.             return b;
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement