SlideShare ist ein Scribd-Unternehmen logo
1 von 20
BACKPORTS
Rolandas Razma

image: Holger
image: Audi
image: Jenny
image: ken
BACKPORTS
image: Michael
image:
SMALL
CHECKBOX
[NSKeyedUnarchiver setClass: [RRLocalizableString class]
forClassName: @"NSLocalizableString"];

image: Angela
image: Johan Wieland
image: European Southern Observatory
- (id)initWithCoder:(NSCoder *)aDecoder {
if( (self = [super init]) ){

_stringsFileKey
= [aDecoder decodeObjectForKey:@"NSKey"];
_developmentLanguageString = [aDecoder decodeObjectForKey:@"NSDev"];

}

}
return self;

- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder {
return [[NSBundle mainBundle] localizedStringForKey: _stringsFileKey
value: _developmentLanguageString
table: ??currentNibName??];
}

image: Don J Schulte
image: Tom Gill
-[NSBundle pathForResource:ofType:]
image: Dan Iggers
- (id)initWithCoder:(NSCoder *)aDecoder {
if( (self = [super init]) ){
_stringsFileKey
= [aDecoder decodeObjectForKey:@"NSKey"];
_developmentLanguageString = [aDecoder decodeObjectForKey:@"NSDev"];
}
return self;
}

- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder {
return [[NSBundle mainBundle] localizedStringForKey: _stringsFileKey
value: _developmentLanguageString
table: [NSBundle currentNibName]];
}
rolandas@razma.lt
@rolandas_razma
github.com/rolandasrazm
a

Weitere ähnliche Inhalte

Andere mochten auch

Οινοποιία Δαρεμά - Βιολογικοί Αμπελώνες
Οινοποιία Δαρεμά - Βιολογικοί ΑμπελώνεςΟινοποιία Δαρεμά - Βιολογικοί Αμπελώνες
Οινοποιία Δαρεμά - Βιολογικοί ΑμπελώνεςAndreas Theocharis
 
formal clothing for men
formal clothing for men formal clothing for men
formal clothing for men Divya Jain
 
Physiological responses of_burkholderia_phytofirmans_strain_ps_jn_colonized_p...
Physiological responses of_burkholderia_phytofirmans_strain_ps_jn_colonized_p...Physiological responses of_burkholderia_phytofirmans_strain_ps_jn_colonized_p...
Physiological responses of_burkholderia_phytofirmans_strain_ps_jn_colonized_p...Andreas Theocharis
 
basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)Guni Sonow
 
Nyr organic opportunity presentation 12.5.13
Nyr organic opportunity presentation  12.5.13Nyr organic opportunity presentation  12.5.13
Nyr organic opportunity presentation 12.5.13Shawna McFetridge
 
Womens wear research
Womens wear research Womens wear research
Womens wear research Divya Jain
 
Assam_the beautiful state of north_east India
Assam_the beautiful state of north_east IndiaAssam_the beautiful state of north_east India
Assam_the beautiful state of north_east IndiaGuni Sonow
 

Andere mochten auch (7)

Οινοποιία Δαρεμά - Βιολογικοί Αμπελώνες
Οινοποιία Δαρεμά - Βιολογικοί ΑμπελώνεςΟινοποιία Δαρεμά - Βιολογικοί Αμπελώνες
Οινοποιία Δαρεμά - Βιολογικοί Αμπελώνες
 
formal clothing for men
formal clothing for men formal clothing for men
formal clothing for men
 
Physiological responses of_burkholderia_phytofirmans_strain_ps_jn_colonized_p...
Physiological responses of_burkholderia_phytofirmans_strain_ps_jn_colonized_p...Physiological responses of_burkholderia_phytofirmans_strain_ps_jn_colonized_p...
Physiological responses of_burkholderia_phytofirmans_strain_ps_jn_colonized_p...
 
basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)basic concept of php(Gunikhan sonowal)
basic concept of php(Gunikhan sonowal)
 
Nyr organic opportunity presentation 12.5.13
Nyr organic opportunity presentation  12.5.13Nyr organic opportunity presentation  12.5.13
Nyr organic opportunity presentation 12.5.13
 
Womens wear research
Womens wear research Womens wear research
Womens wear research
 
Assam_the beautiful state of north_east India
Assam_the beautiful state of north_east IndiaAssam_the beautiful state of north_east India
Assam_the beautiful state of north_east India
 

Kürzlich hochgeladen

Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Kürzlich hochgeladen (20)

Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

iOS Backports

Hinweis der Redaktion

  1. Hi, everyone, I am iOS developer from before official iOS SDK times and I have seen how it grow and evolves. 5 plus years later I can say that it’s a fun ride and WWDC is my xmas and NewYear :)
  2. Time to time Apple release new version of iOS SDK. All those shiny new features that will open up new possibilities and make your life as developer less miserable. I bet every developer eager to use them.
  3. But those other people - you know - like your boss for example, doesn’t understand that time you will waste to support multiple iOS versions will be more expensive than those 3 users that still didn’t updated, and will make code base less maintainable over time.
  4. So you stuck for a few years supporting 2 or 3 versions of SDK. You stuck writing ugly spaghetti code, checking if class or method exist to use different code paths. Your code becomes complex and less maintainable.
  5. But it doesn’t have to be like that. Backports to the rescue! No spaghetti code, no checking for methods or class existence, no impact on users who already updated, and no code to strip after you drop support for older SDK’s.
  6. Good backport is a runtime hook and have no implications on SDK’s that supports functionality natively. ObjC runtime allows to check for class or method existence at runtime and only if they don’t backport dynamically injects them.
  7. It’s not that hard to implement if you know what you doing and it will make your app code way cleaner and more maintainable in a long term. It’s just like another class or category you was writing all along.
  8. Can everything be backported? Most likely yes, but sometimes it could be more complex than the app itself and it would be a waste of time. On the other hand it could be few lines of code and could do things that would be extremely difficult to do otherwise.
  9. I made few of those, maybe you used some, maybe not, but nevertheless I think it’s insanely cool, and I use them in apps I write. None of them was rejected from AppStore for using private API so its totally safe.
  10. For example, base internationalisation backport. You know - that small checkbox in Xcode that makes you life as developer way brighter if you making multilingual applications. Before iOS6 it was very difficult to localize interface builder files…
  11. If you launch App on iOS5 witch doesn’t support base internationalisation you will see NSUnarchyver error that NSLocalizableString doesn’t exist, and thats what we need to backport.
  12. Fortunately NSKeyedUnarchiver has convenient method to replace classes: -[NSKeyedUnarchiver setClass: [RRLocalizableString class] forClassName: @“NSLocalizableString"] this will tell unarchiver to use our class instead of encoded one.
  13. Next, you have to extract info passed into -[RRLocalizableString initWithCoder:]. There is no easy way to find out -[NSCoder decodeObjectForKey:] keys, but the best way I found is to swizzle it and add NSLog.
  14. NSString belongs to class cluster so with -[NSString initWithCoder:] we have to implement -[NSString length] and -[NSString characterAtIndex:] also. They wont be used but they still have to be there.
  15. by swizzling -[NSCoder decodeObjectForKey:] you will find NSKey and NSDev to use in -[NSBundle localizedStringForKey:value:table:], but we still missing “table”.
  16. best way would be to check what file we currently unarchiving, but unfortunately there is no public method on NSCoder for that. So we will have to look for it somewhere else.
  17. Most file operations use -[NSBundle pathForResource:ofType:] to find path to file by name. And sure enough swizzling it gives path we need. All we have to do is store it.
  18. There is several ways to store information in categories, and because we know that only main bundle is used and we need that information only at unarchiving time, we can put it in a static NSString
  19. great success! All what was needed to make this complicated looking backport was several lines of code, and it will save allot of headache for you as developer if you making multilingual applications.
  20. there is no reason to write hard maintainable code just to support older SDK’s, so I invite everyone to check out my backports on github and write some of their own. Thank you.