0

NSInvocation alternative for performSelector:

-

This code doesn’t involve compiler flags or direct runtime calls:

 

  1. SEL selector = @selector(zeroArgumentMethod);
  2. NSMethodSignature *methodSig = [[self class] instanceMethodSignatureForSelector:selector];
  3. NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig];
  4. [invocation setSelector:selector];
  5. [invocation setTarget:self];
  6. [invocation invoke];
SEL selector = @selector(zeroArgumentMethod);
NSMethodSignature *methodSig = [[self class] instanceMethodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSig];
[invocation setSelector:selector];
[invocation setTarget:self];
[invocation invoke];


Resource
NSInvocation allows multiple arguments to be set so unlike performSelector this will work on any method.

And tip:

  1. #pragma clang diagnostic push
  2. #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
  3.     [self.ticketTarget performSelector: self.ticketAction withObject: self];
  4. #pragma clang diagnostic pop
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    [self.ticketTarget performSelector: self.ticketAction withObject: self];
#pragma clang diagnostic pop

 

0

Unzipping Files In iOS Using ZipArchive

-

In this tutorial, I am going to demonstrate how you can zip and unzip files from within your iOS applications. We will be using a third party library called ZipArchive to achieve this. While there are a couple solutions out there to zip and unzip files, I feel that the ZipArchive library was the fastest and easiest way to get up and running.

(more...)

0

.gitignore for Xcode 4

-
Finally, Apple introduced native Git support in Xcode 4. Git is now the standard version control system you can use within Xcode. The Apple engineers did a great job in integrating Git into Xcode 4 … but there is room for improvements ;) Tools like gitx still are essential for me to keep track of all the branches in the Git-repository.
If you want to use Git as the version control system for your Xcode projects, you definitely should use a specific .gitignore file to keep your Git-repository clean.That’s the content of a Xcode4 optimized .gitignore text-file:
  1. # Exclude the build directory
  2. build/*
  3.  
  4. # Exclude temp nibs and swap files
  5. *~.nib
  6. *.swp
  7.  
  8. # Exclude OS X folder attributes
  9. .DS_Store
  10.  
  11. # Exclude user-specific XCode 3 and 4 files
  12. *.mode1
  13. *.mode1v3
  14. *.mode2v3
  15. *.perspective
  16. *.perspectivev3
  17. *.pbxuser
  18. *.xcworkspace
  19. *.xcuserstate
  20. xcuserdata
# Exclude the build directory
build/*

# Exclude temp nibs and swap files
*~.nib
*.swp

# Exclude OS X folder attributes
.DS_Store

# Exclude user-specific XCode 3 and 4 files
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
*.xcuserstate
xcuserdata

one can also specify a global gitignore file in ~/.gitconfig:

  1. [core]
  2. excludesfile = /Users/username/.gitignore
[core]
excludesfile = /Users/username/.gitignore