BuySellAds.com

My book Barcodes with iOS 7 is nearing completion. Buy it now to get early access!
Our DNA is written in Objective-C
Jump

DTFoundation 1.5.4

This update to to DTFoundation is a maintenance release. It adds code coverage monitoring via Coveralls and fixes some very minor issues.

Changes

  • ADDED: Coverage Monitoring via Coveralls
  • ADDED: DTBlockFunctions
  • FIXED: DTZipArchive: completion block would be called twice if uncompressing has error
  • FIXED: Warning in minizip
  • CHANGED: Removed shadow from PieProgressIndicator to fit iOS7 style

The block functions are a convenience for scenarios where you prefer to execute a call synchronously on the main thread if you already are on it, or else dispatch it asynchronously on the next run loop. I have some situations where you don’t want to wait until the next run look (i.e. always do a dispatch_async) because sometimes this causes some problems with animations.

Another scenario might be that you want to avoid a superfluous layoutSubviews and drawing pass if you already know that you want to change some view model values. This way you get the changes in as early as possible and they will get picked up by the subsequent pass through the run loop.

To avoid having to write all this code every time, I’m just adding a C function for it:

void DTBlockPerformSyncIfOnMainThreadElseAsync(void (^block)(void))
{
   if ([NSThread isMainThread])
   {
      // can perform synchronous on main thread
      block();
   }
   else
   {
      // need to perform asynchronous
      dispatch_async(dispatch_get_main_queue(), block);
   }
}

The warning in minizip – or more precisely ioapi.c – is a result of Xcode enabling 64-vs-32-bit warnings due to the advent of arm64. This C-function is part of the open source zLib, which you can also see in Apple’s open source browser. zLib has the beginnings of some 64 bit support, but this is incomplete. This particular warning is a result of using a 32-bit fseek with a potentially 64-bit offset. I have my doubts that this would ever get fixed, so we just squashed the warning with a typecast.

// a bit further up:
 
#define USE_FILE32API
#if defined(USE_FILE32API)
#define fopen64 fopen
#define ftello64 ftell
#define fseeko64 fseek
 
// and the function:
 
static long ZCALLBACK fseek64_file_func (voidpf  opaque, voidpf stream, ZPOS64_T offset, int origin)
{
 
// I added this define as a reminder for future generations (or myself)
#if !defined(USE_FILE32API)
#warning In the following file we are casting to long to squash warning.
#endif
    if(fseeko64((FILE *)stream, (long)offset, fseek_origin) != 0)
                        ret = -1;
 
    return ret;
}

Apparently the author – Mathias Svensson if I am reading the header correctly – has a static define in place to always use 32-bit file API. This replaces 3 64-bit file methods with their 32-bit counterparts and so there is this warning. Interesting things you are finding in somebody else’s C-code from several years ago if you’re compiling with more warnings enabled …

The update is tagged on GitHub and also available via CocoaPods.


Tagged as:

Categories: Updates

%d bloggers like this: