Highlighting TODOs, FIXMEs, ERRORs

: ~25 sec read

I found krakendev's idea quite interesting.

There are two downsides:

  • it will highlight all ERRORs, even in this case:
NSLog(@"ERROR: Reason here");
  • it will highlight code inside frameworks as well.

Sadly, I'm not good with bash, so I don't really know how to improve these downsides, but you might find it helpful, nonetheless. Keeping it for future reference, as well.

SnippetsLab

: ~25 sec read

I personally use Dash (more for the text expanding capabilities and the documentation), but SnippetsLab looks quite interesting as well, just for collecting your snippets - awesome interface with different themes, support for over 100 languages, and a menu bar icon for quick access.

I'm a sucker for clean, dark themes.

[EP] Improving the iCloud sync

: ~40 sec read

When I wrote about iCloud sync, I said the sync logic is the shittiest ever, so this is the first attempt at improving it.

Firstly, the migrateOldData got an update:

EPEvent.data << EPEvent(
  id: Events.last?.id ?? 0 + 1,
  ...
)

init(...) {
  modificationTime = NSDate.timeIntervalSinceReferenceDate()
}

modifyEventInAnyWay() {
  modificationTime = NSDate.timeIntervalSinceReferenceDate()
}

Then the sync.

for iCloudEvent in document.data {
  var addEvent = true

  for localEvent in Events where localEvent.id == iCloudEvent.id {
    if localEvent.lastModification < iCloudEvent.lastModification {
    // Update local events.
    }

    // Inner if block instead of adding it in the where statement,
    // because if iCloud modification is older than local
    // we don't want to add a new event, just not update the local one
    addEvent = false
  }

  // Add new event.
  if addEvent { Events.append(iCloudEvent) }

Gitsh

: ~25 sec read

I saw this little thing today, by the guys from thoughtbot. sh$ gitsh then simply type commands without git:

status
add .
commit -m "Message"
push

Be sure to check their newest iOS open source, as well, Tropos.

[EP] iCloud sync

: ~25 sec read

I already love Swift 2.0.

First, defer, to never forget to enableUpdates for the query

query.disableUpdates()
defer { query.enableUpdates() }
// Do stuff.

Secondly, for x in y where condition loops:

for iCloudEvent in document.data {
  // I know, I know, shittiest sync ever, I will try to improve it at some point.
  for localEvent in Events where localEvent.name == iCloudEvent.name {
    // Update local events.
  }
  // Append to local events.
}