SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Destaque

Οινοποιία Δαρεμά - Βιολογικοί Αμπελώνες
Οινοποιία Δαρεμά - Βιολογικοί ΑμπελώνεςΟινοποιία Δαρεμά - Βιολογικοί Αμπελώνες
Οινοποιία Δαρεμά - Βιολογικοί Αμπελώνες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
 

Destaque (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
 

Último

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

iOS Backports

Notas do Editor

  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.