DTFoundation – Cocoanetics https://www.cocoanetics.com Our DNA is written in Swift Wed, 30 Jun 2021 08:21:32 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.3 39982308 DTFoundation 1.7.18 https://www.cocoanetics.com/2021/06/dtfoundation-1-7-18/ https://www.cocoanetics.com/2021/06/dtfoundation-1-7-18/#comments Wed, 30 Jun 2021 08:20:41 +0000 https://www.cocoanetics.com/?p=10699 This is a maintenance release fixing mostly build issues.

Changes

  • FIXED: Enable building with bitcode
  • FIXED: reduce iOS deployment target to 9
  • FIXED: DTWeakSupport was sometimes not found when building as part of DTCoreText
  • FIXED: [DTASN1] Due to mismatch with protocol the parser was ignoring start end end messages for context

The update has been tagged on GitHub and was pushed to Cocoapods trunk. It’s also available via SPM.

]]>
https://www.cocoanetics.com/2021/06/dtfoundation-1-7-18/feed/ 12 10699
DTFoundation 1.7.14 https://www.cocoanetics.com/2019/09/dtfoundation-1-7-14/ https://www.cocoanetics.com/2019/09/dtfoundation-1-7-14/#respond Tue, 10 Sep 2019 12:14:31 +0000 https://www.cocoanetics.com/?p=10611 Several recent pull requests, as well as an acute deprecation of UIWebView made it necessary to push out this maintenance update. Even more so, because this framework is a dependency of DTCoreText which also needs an update.

Changes

  • FIXED: incorrect public header location for tvOS framework
  • FIXED: Nullability tags for DTReachability, NSString+DTPaths
  • FIXED: Added tvOS support for DTASN1
  • FIXED: Several implicit self retain warnings
  • REMOVED: UIWebView helpers as this causes submission problems

The update is tagged on GitHub as well as available via Cocoapods.

]]>
https://www.cocoanetics.com/2019/09/dtfoundation-1-7-14/feed/ 0 10611
DTFoundation 1.7.11 https://www.cocoanetics.com/2016/09/dtfoundation-1-7-11/ https://www.cocoanetics.com/2016/09/dtfoundation-1-7-11/#respond Mon, 26 Sep 2016 14:07:42 +0000 https://www.cocoanetics.com/?p=10311 With the prior update to DTFoundation having been 5 months ago, there were two main areas where some tweaks were necessary: support for tvOS and fixing a build error on Xcode 8.

Changes

  • FIXED: Xcode 8 build error in Runtime
  • ADDED: tvOS Subspec

Thanks to Ryan Maxwell for the adjustments necessary to for tvOS support. Thanks to Fawaz Tahir for the Xcode 8 compatibility fix.

The update is tagged on GitHub (for Carthage) and also available on Cocoapods.

]]>
https://www.cocoanetics.com/2016/09/dtfoundation-1-7-11/feed/ 0 10311
DTFoundation 1.7.10 https://www.cocoanetics.com/2016/04/dtfoundation-1-7-10/ https://www.cocoanetics.com/2016/04/dtfoundation-1-7-10/#respond Wed, 06 Apr 2016 17:51:54 +0000 https://www.cocoanetics.com/?p=10193 This bug fix release for DTFoundation addresses some build problems that resulted from updating to Xcode 7.3 as well.

Changes

  • FIXED: stringByURLEncoding returned incorrect strings with iOS 9 SDK
  • FIXED: Warnings related to modular header imports
  • FIXED: Compiler warnings for iOS 9
  • FIXED: [DTPieProgressIndicator] now using tintColor by default
  • CHANGED: Moved DTAsyncFileDeleter into separate sub spec

The first issue was severe because the behavior of the mentioned category method was complete wrong. Thanks Mohamed Hafez for reporting this!

I slightly modified DTPieProgressIndicator to use tintColor for the label and image because this makes it work well as subview of a UIVisualEffectsView with vibrancy. iOS always makes all UI elements vibrant that are using the tintColor.

The build problems also resulted in issues with DTCoreText and DTRichTextEditor. This should be fixed now as well, at least when they were caused by Xcode complaining about non-modular headers preventing parts from building.

Thanks for contributing to: Renzo Crisóstomo, Stefan Gugarel and Ian Ynda-Hummel  and René Pirringer

The update is available via CocoaPods and tagged on GitHub.

]]>
https://www.cocoanetics.com/2016/04/dtfoundation-1-7-10/feed/ 0 10193
DTFoundation 1.7.9 https://www.cocoanetics.com/2015/12/dtfoundation-1-7-9/ https://www.cocoanetics.com/2015/12/dtfoundation-1-7-9/#respond Tue, 29 Dec 2015 08:47:46 +0000 https://www.cocoanetics.com/?p=10017 I’m doing this year-end update for DTFoundation to not have any unreleased contributions.

Changes

  • FIXED: Support for app extensions
  • FIXED: Missing resume for data task in URL unshortener
  • CHANGED: Made smart paging delegate outlet so that it can be connected in IB
  • CHANGED: tvOS settings for combining HiDPI artwork, as suggested by Xcode
  • CHANGED: Exclude DTAlertView and DTActionSheet based on min OS instead of max OS
  • CHANGED: Removed deprecated classes from progress HUD demo
  • CHANGED: Xcode 7.1 update
  • FIXED: Unit tests

Those are for the most part clean up changes, the biggest recent changes were made in the previous release. Thanks to Michał Zaborowski and Stefan Gugarel for their contributions to this release.

The update is tagged on GitHub and available via Cocoapods.

 

]]>
https://www.cocoanetics.com/2015/12/dtfoundation-1-7-9/feed/ 0 10017
DTFoundation 1.7.8 https://www.cocoanetics.com/2015/10/dtfoundation-1-7-8/ https://www.cocoanetics.com/2015/10/dtfoundation-1-7-8/#comments Wed, 07 Oct 2015 18:34:04 +0000 http://www.cocoanetics.com/?p=9885 This update for DTFoundation fixes some building problems for tvOS and extensions. Also most of the work happened on DTASN1 in preparation for Kvitto, my new open source framework for reading App Store receipt files.

Changes

  • ADDED: Support for tvOS
  • ADDED: Define to disable code that does not work when building for extensions
  • ADDED: [DTASN1] now part of DTFoundation Core
  • FIXED: [DTASN1] Numbers with more than 4 bytes would not be represented as NSNumber
  • FIXED: [DTASN1] Zero-length strings would cause parsing to assume an error
  • CHANGED: Removed DTZipArchive unit tests that would sometimes randomly fail (timing)

Thanks to Michał Zaborowski and Todd Brannam for the conditional building contributions for tvOS and extensions.

The update is available via Cocoapods and tagged on GitHub.

]]>
https://www.cocoanetics.com/2015/10/dtfoundation-1-7-8/feed/ 1 9885
DTFoundation 1.7.7 https://www.cocoanetics.com/2015/07/dtfoundation-1-7-7/ https://www.cocoanetics.com/2015/07/dtfoundation-1-7-7/#respond Thu, 30 Jul 2015 18:02:25 +0000 http://www.cocoanetics.com/?p=9839 This maintenance update for DTFoundation cleans up a few Xcode 7 and OCLint warnings and fixes an issue in DTSidePanelController.

Changes

  • FIXED: [DTSidePanelController] Panel might get stuck half way opened
  • CHANGED: DTSmartPagingScrollView can now be instantiated from NIB / Storyboard
  • FIXED: Warnings from XCode7
  • FIXED: Some warnings from OCLint

Contributions came from Stefan Gugarel and René Pirringer. Thanks!

The update is available on CocoaPods and tagged on Github.

]]>
https://www.cocoanetics.com/2015/07/dtfoundation-1-7-7/feed/ 0 9839
DTFoundation 1.7.6 https://www.cocoanetics.com/2015/07/dtfoundation-1-7-6/ https://www.cocoanetics.com/2015/07/dtfoundation-1-7-6/#respond Sat, 04 Jul 2015 09:22:16 +0000 https://www.cocoanetics.com/?p=9756 This maintenance update fixes a few bugs in the ASN.1 parser and adds support for modules.

Changes

  • FIXED [DTASN1Parser] 2 Bugs
  • ADDED: Method for SHA1 generation
  • ADDED: iOS Framework

Since iOS 8 is supporting frameworks and iOS 9 being around the corner it made sense to add a DTFoundation framework target for iOS. At the same time, I used this to get it to play nice with modules because this is required up stream with DTCoreText.

The main driving force for the updates in this release was the need to parse In-App Purchase receipts on device. I found a scenario where parsing the ASN.1 data of receipts would fail because a large value turned negative because I was not considering the sign bit.

The update is available via CocoaPods as well as tagged on GitHub.

]]>
https://www.cocoanetics.com/2015/07/dtfoundation-1-7-6/feed/ 0 9756
DTFoundation 1.7.5 https://www.cocoanetics.com/2015/02/dtfoundation-1-7-5/ https://www.cocoanetics.com/2015/02/dtfoundation-1-7-5/#comments Thu, 19 Feb 2015 10:29:55 +0000 http://www.cocoanetics.com/?p=9460 This maintenance update for DTFoundation contains a few fixes for the parsers and other minor fixes.

Changes

  • FIXED: [DTHTMLParser] Implemented check for invalid encoding when auto-detecting HTML encoding
  • FIXED: [DTHTMLParser] Added missing deployment target in pod spec to allow usage of parser under OS X
  • FIXED: [DTASN1Parser] Crash when parsing ASN.1 data containing Latin1 string, instead ignore the string contents
  • FIXED: Improved 64-bit handling in DTCoreGraphicsUtils, DTPieProgressIndicator and UIImage+DTFoundation
  • FIXED: DTPieProgressIndicator would not display properly when instantiated from XIB

This release’s MVP is Jean-Charles Bertin.

The fix for the ASN.1 parser is unfortunately only a workaround. Latin1 strings – if they are incompatible with UTF8 – are now simply getting ignored. This is still better than causing a crash, but a proper implementation would be nice…

I noticed the missing deployment target for OS X when using DTHTMLParser to build a web scraper command line utility. This works quite well for parsing HTML tables. Let me know in the comments if this would make a good tutorial.

The update is available via Cocoapods and tagged on GitHub.

]]>
https://www.cocoanetics.com/2015/02/dtfoundation-1-7-5/feed/ 1 9460
DTFoundation 1.7.4 https://www.cocoanetics.com/2014/12/dtfoundation-1-7-4/ https://www.cocoanetics.com/2014/12/dtfoundation-1-7-4/#respond Tue, 02 Dec 2014 19:33:05 +0000 http://www.cocoanetics.com/?p=9385 This maintenance update to DTFoundation contains several minor fixes and a few new CocoaPods sub specs.

Changes

  • FIXED: Added armv7s to static library targets (iOS)
  • FIXED: [DTZipArchive] unit test would sometimes fail
  • FIXED: Analyzer warnings
  • FIXED: Log message of main thread checker would mention incorrect symbol for debugging
  • ADDED: CocoaPods specs for DTScripting, Debug and Runtime
  • ADDED: Dynamic framework for iOS8
  • REMOVED: Deprecated static framework for iOS

Because Xcode 6 dropped the armv7s architecture from the standard architectures (now only arm64 and armv7) I argue that component vendors need to include armv7s in their static library targets to let the developer using the component decided whether or not to include this architecture. Because of this I added arm7vs to all static lib targets.

Several pesky analyzer warnings were fixed, thanks Chris Wilson!

I have a main thread checker in DTFoundation since February 2013, but only now it is available via Cocoapods sub spec DTFoundation/Debug. Apparently some change (either in Xcode or CocoaPods) causes the symbol name of category methods to include the category name. So the log message was amended to take the method name from the compiler instead of hard coding it. The DTScripting methods are used in our iCatalog products for allowing Objective-C scripting support.

Finally I added a new dynamic framework for iOS 8 and above to match the new dynamic framework for OS X. Xcode would get confused by two iOS targets having the same product name DTFoundation.framework and so I removed the previously existing static framework. Nobody ever was really using this and since it is an ugly hack it had to go. The new dynamic framework allows you to embed it into iOS 8 apps and you get the benefit of dynamic linking. I’m using this in the ProductLayer framework. There I am using some methods from DTFoundation but I don’t want to have to statically link into DTFoundation into a static framework. This way I can have dynamic frameworks for both included in my app and no longer need to duplicate code of DTFoundation.

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

]]>
https://www.cocoanetics.com/2014/12/dtfoundation-1-7-4/feed/ 0 9385
DTFoundation 1.7.3 https://www.cocoanetics.com/2014/09/dtfoundation-1-7-3/ https://www.cocoanetics.com/2014/09/dtfoundation-1-7-3/#respond Tue, 16 Sep 2014 14:11:42 +0000 http://www.cocoanetics.com/?p=9272 This maintenance release for DTFoundation fixes our block-based action sheet and alert view for iOS 8 GM.

Changes

  • FIXED: [DTAlertView] Completion blocks for the buttons are not executed on iOS 8 GM
  • FIXED: [DTActionSheet] Completion blocks for the buttons are not executed on iOS 8 GM

Apple had further modified UIActionSheet for iOS 8 GM and those changes broke the fix that was introduced in DTFoundation 1.7.2. Thank you to René Pirringer, Stefan Gugarel and Ricardo Sánchez-Sáez for working out a fix.

With the changes made by Apple it is no longer possible to piggy-back on the delegate mechanism. If you want to use block-based actions together with the traditional delegate protocol there is now a new  actionSheetDelegate and alertViewDelegate property to set your delegate on instead.

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

]]>
https://www.cocoanetics.com/2014/09/dtfoundation-1-7-3/feed/ 0 9272
DTFoundation 1.7.2 https://www.cocoanetics.com/2014/07/dtfoundation-1-7-2/ https://www.cocoanetics.com/2014/07/dtfoundation-1-7-2/#comments Wed, 23 Jul 2014 13:18:47 +0000 http://www.cocoanetics.com/?p=9231 This maintenance update for DTFoundation fixes a slew of warnings that appear building for iOS 8 only or with Xcode 6.

Changes

  • FIXED: [DTAlertView] Completion blocks for the buttons are not executed on iOS 8
  • FIXED: [DTLog] Deprecation warnings with iOS 8 deployment target
  • FIXED: [DTProgressHUD] Warning about no rootViewController might show if instantiated in app’s first run loop (<= iOS 7)
  • FIXED: [DTSidePanelController] Horizontal swipe gesture interfering with edit gesture on table view
  • FIXED: [DTSidePanelController] Panel sizing issue resulting in black areas showing
  • ADDED: [DTSidePanelController] Support for creation via storyboard

Thanks to René Pirringer and André Mathlener for working out the DTAlertView issue. Thanks to René Swoboda for contributing improvements on DTSidePanelController. Our side panel controller can now also be set up and used in storyboard-based apps.

The update is tagged on GitHub as well as published via CocoaPods.

]]>
https://www.cocoanetics.com/2014/07/dtfoundation-1-7-2/feed/ 2 9231
DTFoundation 1.7.1 https://www.cocoanetics.com/2014/07/dtfoundation-1-7-1/ https://www.cocoanetics.com/2014/07/dtfoundation-1-7-1/#comments Wed, 02 Jul 2014 14:04:38 +0000 http://www.cocoanetics.com/?p=9212 This minimalistic update to DTFoundation adds a helper method for loading small animated GIFs. It’s a hotfix release because no other functionality was modified.

Changes

  • ADDED: DTAnimatedGIF in separate static lib / subspec
  • FIXED: DTActionSheet “noticeable delay” choosing an action

It may come as a surprise to you, but iOS does not natively support animated GIFs. If you load one via UIImage all you get is the first frame statically showing. UIImage and UIImageView do have a facility for displaying animated images, but there you can only specify a total animation duration and an array of images.

When researching about animated GIFs with iOS I found two kinds of approaches:

  1. Compatible with UIImageView
  2. High-Performance custom views for displaying GIFs, with on-demand loading and caching

There are several examples for both, Mattt Thompson’s AnimatedGIFImageSerialization being one for number 1 and Flipboard’s approach being one for number 2. Mattt even goes as far as swizzeling [UIImage imageNamed:] to add the missing support. But as far as I can tell he is only calculating the entire duration of the animation with individual frames playing at equal durations.

Rob Mayoff offers a solution for the problem of varying frame durations by finding the shortest duration that all frame durations are a multiple of. This way you can duplicate individual frames thus duplicating the frame’s duration. Rob’s approach gave me the most inspiration, although I thought the implementation to be somewhat clunky. I mixed his approach with a more elegant recursive method for finding the greatest common factor and – supposedly – the way WebKit calculates frame durations.

Approach number 1 might have some performance bottlenecks with very large images. For these kind of scenarios approach number 2 is definitely the better option. But for introducing support for playing low-weight GIFs in DTCoreText this is probably just as fine.

The update to DTFoundation is tagged on GitHub and also available via Cocoapods.

]]>
https://www.cocoanetics.com/2014/07/dtfoundation-1-7-1/feed/ 1 9212
DTFoundation 1.7.0 https://www.cocoanetics.com/2014/06/dtfoundation-1-7-0/ https://www.cocoanetics.com/2014/06/dtfoundation-1-7-0/#respond Mon, 02 Jun 2014 16:06:21 +0000 http://www.cocoanetics.com/?p=9151 This release of DTFoundation contains fixes for the most part, but also one new class DTProgressHUD. Also it is the first released via the new CocoaPods Trunk mechanism. This is why it gets a minor release number bump.

Changes

  • ADDED: DTProgressHUD
  • FIXED: Deprecation warning in DTActivityTitleView when compiling >= iOS 7
  • FIXED: Some targets where built only for 64-bit
  • FIXED: Warning about weak variable being accessed multiple times

DTProgressHUD was developed by Stefan Gugarel to have a modern HUD with a nice iOS 7 look. We had an older private version of this in some of our projects, Stefan cleaned it up and modernised it and not it is open source.

Thanks for other contributed fixes go to Jean-Charles Bertin and Ben Globism.

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

]]>
https://www.cocoanetics.com/2014/06/dtfoundation-1-7-0/feed/ 0 9151
DTFoundation 1.6.3 https://www.cocoanetics.com/2014/05/dtfoundation-1-6-3/ https://www.cocoanetics.com/2014/05/dtfoundation-1-6-3/#respond Wed, 07 May 2014 13:03:16 +0000 http://www.cocoanetics.com/?p=9108 This maintenance update to DTFoundation fixes an issue with DTFolderMonitor. The update is available via GitHub tag or Cocoapods.

Changes

  • FIXED: DTFolderMonitor might cause exception if monitoring is started and stopped quickly in succession
  • CHANGED: Migrated unit testing to XCTest

Sebastian Hunkeler provided the main fix of this release. Thanks!

Builds kept failing on Travis-CI and in an attempt to fix this I migrated to XCTest. I had to perform the migration manually because the refactoring method of Xcode failed me. When this didn’t fix the build I found that an old version of xctool was the culprit.

This is how I changed my build file to force an update to xctool. The problem I was having had been fixed as of version 0.1.15 of xctool while Travis-CI had only 0.1.14 preinstalled on the build nodes. It might be a good idea to add such an update to each build script.

---
language: objective-c
 
before_install: 
 - brew update
 
install: 
 - brew upgrade xctool
 - sudo easy_install cpp-coveralls
 
script: 
 - xctool -project DTFoundation.xcodeproj -scheme "DTSidePanels Demo" build -sdk iphonesimulator -arch i386 ONLY_ACTIVE_ARCH=NO
 - xctool -project DTFoundation.xcodeproj -scheme "DTReachability Demo" build -sdk iphonesimulator -arch i386 ONLY_ACTIVE_ARCH=NO
 - xctool -project DTFoundation.xcodeproj -scheme "DTZipArchive Demo" build -sdk iphonesimulator -arch i386 ONLY_ACTIVE_ARCH=NO
 - xctool -project DTFoundation.xcodeproj -scheme "Static Library" build test -sdk iphonesimulator -arch i386 ONLY_ACTIVE_ARCH=NO -configuration Coverage
 
after_success:
  - ./coveralls.rb --extension m --exclude-folder Demo --exclude-folder Test --exclude-folder Externals

Thanks to Cédric Luthi for providing the idea to do brew update and upgrade in the before_install and install sections. Richard Lee deserves some of the credit too for being the first to respond to my question.

As an afterthought I also wanted to add my documentation completeness test which requires appledoc to be installed on build nodes. Unfortunately appledoc went missing when Travis-CI updated to Xcode 5.1. So this has to wait until the next release.

]]>
https://www.cocoanetics.com/2014/05/dtfoundation-1-6-3/feed/ 0 9108
DTFoundation 1.6.2 https://www.cocoanetics.com/2014/03/dtfoundation-1-6-2/ https://www.cocoanetics.com/2014/03/dtfoundation-1-6-2/#respond Wed, 12 Mar 2014 10:24:46 +0000 http://www.cocoanetics.com/?p=9030 This maintenance release addresses a few minor build issues with the new Xcode 5.1.

Changes

  • ADDED: DTCustomColoredAccessory gains DTCustomColoredAccessoryTypeSquare
  • CHANGED: Made DTASN1Parser usable as stand-alone library
  • FIXED: DTHTMLParser pod build problem if Xcode installed in path containing spaces
  • FIXED: Xcode 5.1 warnings

The update is tagged on GitHub and also released via Cocoapods.

]]>
https://www.cocoanetics.com/2014/03/dtfoundation-1-6-2/feed/ 0 9030
DTFoundation 1.6.1 https://www.cocoanetics.com/2013/12/dtfoundation-1-6-1/ https://www.cocoanetics.com/2013/12/dtfoundation-1-6-1/#respond Wed, 18 Dec 2013 12:08:24 +0000 http://www.cocoanetics.com/?p=8888 This maintenance release of DTFoundation fixes a few bugs.

Changes

  • FIXED: Typo in DTFolderMonitor causing build to fail in some build scenarios
  • FIXED: DTSidePanelController panel jumping in rare cases
  • FIXED: DTReachability exception when specifying an invalid domain for monitoring

Thanks to René Pirringer for contributing the majority of the fixes in this release.

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

]]>
https://www.cocoanetics.com/2013/12/dtfoundation-1-6-1/feed/ 0 8888
DTFoundation 1.6.0 https://www.cocoanetics.com/2013/11/dtfoundation-1-6-0/ https://www.cocoanetics.com/2013/11/dtfoundation-1-6-0/#comments Wed, 13 Nov 2013 14:47:11 +0000 http://www.cocoanetics.com/?p=8828 There are some API changes in this release of DTFoundation that require a bump of the minor version.

Changes

  • CHANGED: DTReachability now passes DTReachabilityInformation to observers
  • CHANGED: DTReachability revamped to allow monitoring custom hosts, no longer a singleton
  • FIXED: Missing Code Coverage monitoring
  • CHANGED: Refactored DTZipArchive and added more unit tests for GZip
  • CHANGED: Prefixed some C-functions to avoid conflicts
  • FIXED: Analyze Warnings
  • FIXED: Some 64-bit and Xcode 4/5 build issues

This release’s MVP is René Pirringer for adapting DTReachability to no longer be only a singleton. This was necessary so that he can better unit test his code using it, because working with instances of it allows it to be mocked. He also adapted the API to pass a DTReachabilityInformation instead of the raw network flags. This allows for simple convenience methods like -isReachable as opposed to having to check the flags yourself.

I took the opportunity and dusted off the read me. I added “programming guides” which are basically lists of the components contained in the various sub specs. Also I created a rudimentary setup guide.

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

]]>
https://www.cocoanetics.com/2013/11/dtfoundation-1-6-0/feed/ 3 8828
DTFoundation 1.5.4 https://www.cocoanetics.com/2013/10/dtfoundation-1-5-4/ https://www.cocoanetics.com/2013/10/dtfoundation-1-5-4/#comments Fri, 04 Oct 2013 16:12:08 +0000 http://www.cocoanetics.com/?p=8729 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.

]]>
https://www.cocoanetics.com/2013/10/dtfoundation-1-5-4/feed/ 4 8729
DTFoundation 1.5.2 https://www.cocoanetics.com/2013/08/dtfoundation-1-5-2/ https://www.cocoanetics.com/2013/08/dtfoundation-1-5-2/#comments Wed, 14 Aug 2013 13:13:04 +0000 http://www.cocoanetics.com/?p=8556 This update for DTFoundation fixes issues with DTLog and DTHTMLParser and adds a few new utility methods.

Changes

  • ADDED: Method for duplicating template image tinting under iOS 6
  • ADDED: DTLog function for retrieving current app log messages
  • ADDED: DTLog function for duplicating NSLog but using ASL and specifying severity level
  • FIXED: DTLog issue when being called from C-function
  • FIXED: DTHTMLParser would not accumulate characters if no tag start and end delegate methods were set

The newly added method in UIImage+DTFoundation allows for creating tinted images from template images, similar to what will be happening in a future iOS version.

UIImage *buttonImage = [UIImage imageNamed:@"Button"];
UIImage tintedImage = [buttonImage imageMaskedAndTintedWithColor:[UIColor redColor]];

The issue in DTHTMLParser came to light when I was researching the fastest method for replacing HTML entities in a string. Turns out that DTHTMLParser is the fastest because it uses the highly optimized libxml2’s HTML parser. But to use it you need to instantiate it and take the result from parser:foundCharacters:. Before I fixed the above mentioned issue you would not get any result because this minimal example does not need the tag begin and end delegate methods.

@implementation AppDelegate
{
  NSString *_convertedString;
}
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	NSString *string = @"Some text &amp; some entities";
	NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
 
	DTHTMLParser *parser = [[DTHTMLParser alloc] initWithData:data encoding:NSUTF8StringEncoding];
	parser.delegate = self;
 
	BOOL b = [parser parse];
 
	NSLog(@"converted %@", _convertedString);
 
  // ...
}
 
- (void)parser:(DTHTMLParser *)parser foundCharacters:(NSString *)string
{
	_convertedString = [string copy];
}

From my experiments with the new DTLog functionality, I also added a method to do the same as NSLog, but also be able to specify a log level. And there is now a method to retrieve the current app’s log messages. With that you could implement a user-facing feature to send the log messages to your support email address. The Apple System Log facility on iOS filters does display the least important two levels (info and debug), but does not store them in the log message database. Contrary to OS X there is no method to change this. So if you use info and debug messages you should probably not rely on ASL to keep them for you. Instead you would append them to a text file, possibly only if the user switches on debugging info in the app settings.

I made a change to the method name parameter so that it works both in an Objective-C method as well as a C-function. Turns out in both cases the __PRETTY_FUNCTION__ macro gives us a nice context for our error messages. With this change you can use the DTLog* macros in both worlds with ease. Please refer to the DTLog introductory article to learn how to use that.

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

]]>
https://www.cocoanetics.com/2013/08/dtfoundation-1-5-2/feed/ 2 8556