Цель доклада — вдохновить разработчиков на более глубокое изучение возможностей Objective-C Runtime, показать способы исследования системы, воодушевить аудиторию на эксперименты.
В докладе показаны несколько примеров использования Objective-C Runtime для решения нетипичных задач. Первый пример - реализация простого KVO своими руками тремя способами. Вторым примером показана полезность исследования приватных классов. Рассказано, как во время работы программы получить информацию о протянутых IBOutlet и IBAction в xib и storyboard. В каждом примере присутствуют особенности реализации, на которых сделан акцент и показаны варианты решения или обхода.
The document provides an overview of new features introduced in C# 6.0, including static using, string interpolation, dictionary initializers, auto-property initializers, nameof expression, await in catch/finally blocks, null conditional operator, expression-bodied members, and extension methods used with static using. Code examples are provided to demonstrate the usage of each new feature.
This document discusses using Jasmine to test JavaScript code. It describes Jasmine as a behavior driven development framework for JavaScript testing. It then provides instructions on installing Jasmine, creating spec files to contain test cases, and including source code files. The document uses an example of testing a master-slave checkbox relationship to demonstrate how to set up tests, DOM elements, and code the tests against the actual code implementation.
The document discusses the Apache Commons project, which develops reusable Java components. It notes that Commons components allow for faster and smaller development by avoiding reinventing common functions. The document outlines several active Commons components like Collections, IO, Lang, and Logging, as well as sandbox and dormant components. It emphasizes that 80% of Commons components have no dependencies on each other, promoting flexibility and reuse.
The zen of async: Best practices for best performance
The document discusses async/await in .NET and C#. It is aimed at .NET library developers to help them understand when and how to properly implement async methods. The key topics covered are getting the right mental model for async/await, knowing when not to use async, avoiding allocations, and minimizing suspensions. Examples are provided of manually caching tasks to improve performance compared to unnecessary allocations.
The document provides an overview of the Spock testing framework for Java Virtual Machine (JVM) applications. It describes Spock as a behavior-driven development (BDD) testing tool that can be used for both unit and system tests. Spock tests use a given-when-then structure and various blocks like setup, cleanup, and where to define fixtures, exercise code, and make assertions. It also supports features like parameterized tests, helper methods, and powerful assertions.
This document discusses UIPickerView and NSArray in iOS app development. It includes sections on NSArray classes like NSArray and NSMutableArray, how to initialize and access array objects. It also covers the UIPickerView, UIPickerViewDataSource, and UIPickerViewDelegate protocols. Example projects are described that show how to generate a UIPickerView programmatically or using a XIB file and populate it with array data. Projects also demonstrate handling selection of multiple components and dependent picker views.
The document provides an agenda for a talk on modeling a Rubik's Cube in JavaScript. It begins with an introduction to scripting languages and ECMAScript. It then discusses modeling a Rubik's Cube by first walking through the code, then modeling the cube and finding moves to solve it. The document covers topics like scripting languages, ECMAScript, object-oriented programming concepts in JavaScript, and modeling a Rubik's Cube to be manipulated programmatically.
V8 is the JavaScript engine used in Google Chrome. It is open source and written in C++ with some parts implemented in embedded JavaScript. V8 uses just-in-time compilation, precise garbage collection, inline caching, and hidden classes to optimize performance. It supports 64-bit versions and has advantages like C-like syntax and bit operations. While documentation is limited, it allows embedding JavaScript in C++ applications and extending it with user libraries.
This document discusses several popular Java libraries including:
- Dependency injection frameworks like Guice and Spring
- Logging with SLF4J
- Collections and utilities with Guava
- HTTP clients like OkHttp
- Reactive programming with RxJava
- REST with Retrofit
- Asynchronous programming with JDeferred
- Event handling with MBassador
- Code generation with Lombok and ByteBuddy
- Testing utilities like JUnitParams, Mockito, Jukito, and Spock
- Waiting assertions with Awaitility and REST testing with Rest-assured.
This document provides an overview of Scala and compares it to Java. It discusses Scala's object-oriented and functional capabilities, how it compiles to JVM bytecode, and benefits like less boilerplate code and support for functional programming. Examples are given of implementing a simple Property class in both Java and Scala to illustrate concepts like case classes, immutable fields, and less lines of code in Scala. The document also touches on Java interoperability, learning Scala gradually, XML processing capabilities, testing frameworks, and tool/library support.
MongoDB is the trusted document store we turn to when we have tough data store problems to solve. For this talk we are going to go a little bit off the path and explore what other roles we can fit MongoDB into. Others have discussed how to turn MongoDB’s capped collections into a publish/subscribe server. We stretch that a little further and turn MongoDB into a full fledged broker with both publish/subscribe and queue semantics, and a the ability to mix them. We will provide code and a running demo of the queue producers and consumers. Next we will turn to coordination services: We will explore the fundamental features and show how to implement them using MongoDB as the storage engine. Again we will show the code and demo the coordination of multiple applications.
CQRS stands for Command Query Responsibility Segregation. That is, that command stack and query stack are designed separately. This leads to a dramatic simplification of design and potential enhancement of scalability.
Events are a new trend in software industry. In real-world, we perform actions and these actions generate a reaction. Event Sourcing is about persisting events and rebuilding the state of the aggregates from recorded events.
In this talk I will share a lot of examples about how to effective implementing CQRS and Event Sourcing with RavenDB
This document provides an overview of moving from C++ to Objective-C. It discusses key differences in syntax between the two languages, including differences in class and method declarations. It also covers Objective-C specific topics like protocols, properties, memory management using retain/release, and the role of the NSAutoreleasePool in autoreleasing objects. The document is intended to act as a bridge for developers familiar with C++ to understand fundamental concepts for working with Objective-C.
The document discusses working with code abstract syntax trees (ASTs). It provides examples of parsing code into ASTs using libraries like Esprima, querying ASTs using libraries like grasp-equery, constructing and transforming ASTs, and generating code from ASTs. It introduces aster, an AST-based code builder that allows defining reusable AST transformations as plugins and integrating AST-based builds into generic build systems like Grunt and Gulp. Aster aims to improve on file-based builders by working directly with ASTs in a streaming fashion.
Phactory is an alternative to database fixtures for defining test data in PHP unit tests. It allows developers to define database objects in code and dynamically create them, rather than loading static datasets. Phactory provides a lightweight ORM and works with MySQL, SQLite, and MongoDB. It supports defining object blueprints, creating objects with associations, retrieving objects, and integrating with PHPUnit for testing database code.
Great design patterns are reusable, modular expressions of what’s going on in your code. They allow you to communicate to other developers simply by the way you code, in addition to being easily maintainable themselves. Put simply, patterns are the available tools in the developer’s toolbox.
In this presentation, I review a few common patterns, their advantages/disadvantages, and how they can be implemented.
The source for this presentation can be found here: https://github.com/derekbrown/designpatterns
The document discusses the Objective-C runtime and provides an overview of its main components and functions. It describes how the runtime works with classes, instances, methods, and message passing. It also covers topics like method resolution, forwarding, and method swizzling. Code examples are provided to illustrate concepts like forwarding messages and swizzling methods. URLs are included for additional Objective-C runtime references and documentation.
Objective-C is an object-oriented programming language that uses message passing to communicate between objects. Objects are represented as C structs with a pointer to their class. The class struct contains metadata about the class like its name, methods, and properties. Objective-C uses a dynamic runtime that allows objects to be modified at runtime via mechanisms like method swizzling and isa swizzling.
The document discusses iPhone app development using Objective-C. It covers the basics of getting started, including what is needed to begin like a Mac, Xcode, and an iPhone. It then explains key Objective-C concepts like classes, methods, and memory management using retain counts. The document also discusses unit testing iOS apps using OCUnit and some Xcode tips. It emphasizes testing first and concludes by noting the market demands more apps and there is room for improvement.
The document shows examples of using blocks and closures in Objective-C and C++, including passing blocks as parameters to functions and defining block types. It also demonstrates capturing values from outer scopes within blocks by copying blocks. Various block examples are provided to illustrate block syntax and usage.
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
While Singletons have become a Pattern-Non-Grata over the years, you still find it surprisingly often in PHP applications and frameworks. This talk will explain what the Singleton pattern is, how it works in PHP and why you should avoid it in your application.
The document discusses several JavaScript unit testing frameworks: QUnit, Jasmine, and YUITest. It provides overviews of each framework including features and how to set them up. For YUITest specifically, it describes how to create test cases and test suites, use assertions, mocks, asynchronous tests, and more. The document serves as a guide to using the YUITest framework for JavaScript unit testing.
The document discusses reconsidering design patterns and some of their common criticisms. It argues that overuse of patterns can lead to problems like hidden coupling and lack of flexibility. It also discusses alternatives to traditional patterns that allow for easier testing, evolution and flexibility through approaches like dependency injection, composition over inheritance, and separating behavior from structure using strategies. Overall it advocates an approach that focuses on communication, flexibility and reducing coupling rather than rigidly applying patterns as templates.
The document provides an overview of new features introduced in C# 6.0, including static using, string interpolation, dictionary initializers, auto-property initializers, nameof expression, await in catch/finally blocks, null conditional operator, expression-bodied members, and extension methods used with static using. Code examples are provided to demonstrate the usage of each new feature.
Testing your javascript code with jasmineRubyc Slides
This document discusses using Jasmine to test JavaScript code. It describes Jasmine as a behavior driven development framework for JavaScript testing. It then provides instructions on installing Jasmine, creating spec files to contain test cases, and including source code files. The document uses an example of testing a master-slave checkbox relationship to demonstrate how to set up tests, DOM elements, and code the tests against the actual code implementation.
The document discusses the Apache Commons project, which develops reusable Java components. It notes that Commons components allow for faster and smaller development by avoiding reinventing common functions. The document outlines several active Commons components like Collections, IO, Lang, and Logging, as well as sandbox and dormant components. It emphasizes that 80% of Commons components have no dependencies on each other, promoting flexibility and reuse.
The document discusses async/await in .NET and C#. It is aimed at .NET library developers to help them understand when and how to properly implement async methods. The key topics covered are getting the right mental model for async/await, knowing when not to use async, avoiding allocations, and minimizing suspensions. Examples are provided of manually caching tasks to improve performance compared to unnecessary allocations.
The document provides an overview of the Spock testing framework for Java Virtual Machine (JVM) applications. It describes Spock as a behavior-driven development (BDD) testing tool that can be used for both unit and system tests. Spock tests use a given-when-then structure and various blocks like setup, cleanup, and where to define fixtures, exercise code, and make assertions. It also supports features like parameterized tests, helper methods, and powerful assertions.
This document discusses UIPickerView and NSArray in iOS app development. It includes sections on NSArray classes like NSArray and NSMutableArray, how to initialize and access array objects. It also covers the UIPickerView, UIPickerViewDataSource, and UIPickerViewDelegate protocols. Example projects are described that show how to generate a UIPickerView programmatically or using a XIB file and populate it with array data. Projects also demonstrate handling selection of multiple components and dependent picker views.
The document provides an agenda for a talk on modeling a Rubik's Cube in JavaScript. It begins with an introduction to scripting languages and ECMAScript. It then discusses modeling a Rubik's Cube by first walking through the code, then modeling the cube and finding moves to solve it. The document covers topics like scripting languages, ECMAScript, object-oriented programming concepts in JavaScript, and modeling a Rubik's Cube to be manipulated programmatically.
V8 is the JavaScript engine used in Google Chrome. It is open source and written in C++ with some parts implemented in embedded JavaScript. V8 uses just-in-time compilation, precise garbage collection, inline caching, and hidden classes to optimize performance. It supports 64-bit versions and has advantages like C-like syntax and bit operations. While documentation is limited, it allows embedding JavaScript in C++ applications and extending it with user libraries.
This document discusses several popular Java libraries including:
- Dependency injection frameworks like Guice and Spring
- Logging with SLF4J
- Collections and utilities with Guava
- HTTP clients like OkHttp
- Reactive programming with RxJava
- REST with Retrofit
- Asynchronous programming with JDeferred
- Event handling with MBassador
- Code generation with Lombok and ByteBuddy
- Testing utilities like JUnitParams, Mockito, Jukito, and Spock
- Waiting assertions with Awaitility and REST testing with Rest-assured.
This document provides an overview of Scala and compares it to Java. It discusses Scala's object-oriented and functional capabilities, how it compiles to JVM bytecode, and benefits like less boilerplate code and support for functional programming. Examples are given of implementing a simple Property class in both Java and Scala to illustrate concepts like case classes, immutable fields, and less lines of code in Scala. The document also touches on Java interoperability, learning Scala gradually, XML processing capabilities, testing frameworks, and tool/library support.
MongoDB is the trusted document store we turn to when we have tough data store problems to solve. For this talk we are going to go a little bit off the path and explore what other roles we can fit MongoDB into. Others have discussed how to turn MongoDB’s capped collections into a publish/subscribe server. We stretch that a little further and turn MongoDB into a full fledged broker with both publish/subscribe and queue semantics, and a the ability to mix them. We will provide code and a running demo of the queue producers and consumers. Next we will turn to coordination services: We will explore the fundamental features and show how to implement them using MongoDB as the storage engine. Again we will show the code and demo the coordination of multiple applications.
Implementing CQRS and Event Sourcing with RavenDBOren Eini
CQRS stands for Command Query Responsibility Segregation. That is, that command stack and query stack are designed separately. This leads to a dramatic simplification of design and potential enhancement of scalability.
Events are a new trend in software industry. In real-world, we perform actions and these actions generate a reaction. Event Sourcing is about persisting events and rebuilding the state of the aggregates from recorded events.
In this talk I will share a lot of examples about how to effective implementing CQRS and Event Sourcing with RavenDB
This document provides an overview of moving from C++ to Objective-C. It discusses key differences in syntax between the two languages, including differences in class and method declarations. It also covers Objective-C specific topics like protocols, properties, memory management using retain/release, and the role of the NSAutoreleasePool in autoreleasing objects. The document is intended to act as a bridge for developers familiar with C++ to understand fundamental concepts for working with Objective-C.
AST - the only true tool for building JavaScriptIngvar Stepanyan
The document discusses working with code abstract syntax trees (ASTs). It provides examples of parsing code into ASTs using libraries like Esprima, querying ASTs using libraries like grasp-equery, constructing and transforming ASTs, and generating code from ASTs. It introduces aster, an AST-based code builder that allows defining reusable AST transformations as plugins and integrating AST-based builds into generic build systems like Grunt and Gulp. Aster aims to improve on file-based builders by working directly with ASTs in a streaming fashion.
Phactory is an alternative to database fixtures for defining test data in PHP unit tests. It allows developers to define database objects in code and dynamically create them, rather than loading static datasets. Phactory provides a lightweight ORM and works with MySQL, SQLite, and MongoDB. It supports defining object blueprints, creating objects with associations, retrieving objects, and integrating with PHPUnit for testing database code.
Great design patterns are reusable, modular expressions of what’s going on in your code. They allow you to communicate to other developers simply by the way you code, in addition to being easily maintainable themselves. Put simply, patterns are the available tools in the developer’s toolbox.
In this presentation, I review a few common patterns, their advantages/disadvantages, and how they can be implemented.
The source for this presentation can be found here: https://github.com/derekbrown/designpatterns
The document discusses the Objective-C runtime and provides an overview of its main components and functions. It describes how the runtime works with classes, instances, methods, and message passing. It also covers topics like method resolution, forwarding, and method swizzling. Code examples are provided to illustrate concepts like forwarding messages and swizzling methods. URLs are included for additional Objective-C runtime references and documentation.
Objective-C is an object-oriented programming language that uses message passing to communicate between objects. Objects are represented as C structs with a pointer to their class. The class struct contains metadata about the class like its name, methods, and properties. Objective-C uses a dynamic runtime that allows objects to be modified at runtime via mechanisms like method swizzling and isa swizzling.
The document discusses iPhone app development using Objective-C. It covers the basics of getting started, including what is needed to begin like a Mac, Xcode, and an iPhone. It then explains key Objective-C concepts like classes, methods, and memory management using retain counts. The document also discusses unit testing iOS apps using OCUnit and some Xcode tips. It emphasizes testing first and concludes by noting the market demands more apps and there is room for improvement.
The document shows examples of using blocks and closures in Objective-C and C++, including passing blocks as parameters to functions and defining block types. It also demonstrates capturing values from outer scopes within blocks by copying blocks. Various block examples are provided to illustrate block syntax and usage.
This document outlines topics covered in a lecture on object oriented JavaScript using the Prototype framework, including:
- Revision of object oriented JavaScript concepts like objects, prototypes, and classes
- Prototype framework utilities like $, $$ and Enumerable
- Extending DOM elements using Prototype methods
- Templates, form management, and getting element dimensions
- Event handling and classes/inheritance in Prototype
- JSON encoding/parsing
- Ajax utilities like Ajax.Request and Ajax.Updater
The document discusses code generation and abstract syntax tree (AST) transformations. It provides an overview of Project Lombok, a Java library that generates boilerplate code through annotation processing and AST transformations. It also discusses how to analyze and transform code by visiting and rewriting AST nodes, giving examples of checking for null checks and instanceof expressions.
JavaScript objects must implement certain standard properties and methods. Objects have a prototype property that is either an object or null, and prototype chains must have finite length. The typeof operator returns a string indicating the type of a variable or value. JavaScript supports basic types like undefined, null, boolean, number, string, and object. Functions are objects that can be called, and have properties like length and arguments. Variables declared with var have function scope, while variables assigned without var have global scope. Arrays, objects, and functions can be declared using various syntaxes. JavaScript uses prototypal inheritance rather than classes.
The document discusses abstract syntax tree (AST) transformations in Groovy and Java. It covers several tools and techniques for AST transformations including Lombok, Groovy, CodeNarc, IntelliJ IDEA, Mirah macros, and how they allow generating code, performing static analysis, and rewriting code at compile time through analyzing and modifying the AST. The key topics are how these tools work by compiling code to an AST, analyzing and modifying the AST nodes, and sometimes generating source code from the transformed AST.
Software written in such way might look unconventional, and has a bit of a learning curve. The talk is to show that the advantages it brings make it a viable choice.
The document discusses the Objective-C runtime system. It describes the runtime as an operating system for the Objective-C language that allows interacting with classes, objects, and methods through direct calls or NSObject methods. Key concepts covered include classes, metaclasses, messaging, dynamic method resolution, message forwarding, method swizzling, and key-value observing. The runtime provides low-level access to aspects of Objective-C normally hidden from programmers.
The document discusses code generation on the JVM using various tools and frameworks. It provides an overview of Lombok for generating Java boilerplate code, Groovy AST transformations, CodeNarc for static analysis, and Spock, GContracts, and Groovy++ for framework-oriented code generation. It also discusses generating code at compile time using abstract syntax trees.
This document provides an overview of the history and evolution of JavaScript. It discusses key dates and specifications including its first appearance in 1995 in Netscape Navigator 2.0 and the standardization process in the late 1990s. The document also covers JavaScript's core features like being dynamic, single-threaded, asynchronous and event-driven. It describes JavaScript's data types, objects, functions and common array methods. Overall, the document presents a comprehensive introduction to JavaScript from its origins to modern usage.
The document provides an overview of various Objective-C concepts including classes, objects, methods, properties, protocols, categories, dictionaries, property lists, user defaults, errors, delegates, callbacks, and table views. It discusses core classes like NSString, NSArray, NSDictionary, and NSMutableDictionary. It covers concepts like inheritance, polymorphism, and memory management using retain, release, and autorelease. The document also provides examples of declaring and defining classes, creating class instances, and implementing table views with custom cells.
This document discusses interoperability between Swift and Objective-C. It covers topics like initializing and interacting with Objective-C APIs from Swift, bridging optionals, nullability, lightweight generics, extensions, closures and blocks, object comparison, hashing, selectors, key paths, and more. It also discusses adopting Cocoa design patterns like delegation, lazy initialization, error handling, and key-value observing when using Swift with Cocoa.
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
Classes and Object-oriented Programming:
Classes: Creating a Class, The Self Variable, Constructor, Types of Variables, Namespaces, Types of Methods (Instance Methods, Class Methods, Static Methods), Passing Members of One Class to Another Class, Inner Classes
Inheritance and Polymorphism: Constructors in Inheritance, Overriding Super Class Constructors and Methods, The super() Method, Types of Inheritance, Single Inheritance, Multiple Inheritance, Method Resolution Order (MRO), Polymorphism, Duck Typing Philosophy of Python, Operator Overloading, Method Overloading, Method Overriding
Abstract Classes and Interfaces: Abstract Method and Abstract Class, Interfaces in Python, Abstract Classes vs. Interfaces,
The document discusses functions and objects in JavaScript. It defines a function as a reusable block of code that performs operations to fulfill a specific task. Functions can be invoked to execute their code. Objects are collections of properties and methods that represent real-world entities. The document describes how to create user-defined functions and objects in JavaScript, including defining properties and methods. It also provides examples of the built-in String and Math objects and their properties and methods.
The document provides an outline of a lecture on object-oriented JavaScript and inheritance. It covers key concepts like objects, properties, methods, object literals, constructor functions, and prototype inheritance. It discusses creating and accessing objects, adding and removing properties, passing objects by reference, comparing objects, and the prototype chain. Private and privileged methods and properties are explained. Different approaches to implementing inheritance like prototype chaining are also summarized.
The document discusses JavaScript and some of its key features:
- JavaScript is the programming language of the web browser and was originally developed by Netscape under different names before being standardized.
- JavaScript uses a prototypal object model instead of classes, with objects inheriting directly from other objects via prototypal inheritance chains rather than from classes.
- The "new" keyword is used to create objects but can give the misleading impression of classes; functions can also be used to create objects without "new" by returning the object.
Similar to «Objective-C Runtime в примерах» — Алексей Сторожев, e-Legion (20)
This document discusses Alibaba Mobile's ecosystem and strategies for launching products in various markets. It covers Alibaba's entrance into the mobile internet world through smartphones, operating systems, and application stores/browsers. It then discusses how Alibaba builds its ecosystem through big data, content monetization, and various traffic sources. The document outlines Alibaba's strategies for global markets and provides real examples of products launched in India and Indonesia, including services related to cricket, music, video, Facebook notifications, e-commerce, and news.
The Dining Man: how does Afisha Restaurants change the behavioral patterns of choice and payments in cafes and restaurants. Based on the real experience of Project Manager
This document provides a summary of Marvin Liao's 2016 investment outlook. It discusses 7 trends that early stage tech investors should pay attention to:
1. Virtual and augmented reality being the next major engagement platform, as AR/VR startups raised $658M in 2015.
2. The internet of everything (IoT), as IoT startups raised over $1.9B in 2015.
3. FinTech as a major growth area, with Asian FinTech startups raising $3.5B in 2015 and US startups raising $3B in Q1 2015.
4. Millennials now being the largest demographic group and redefining smartphone usage and preferences.
RxJava is a library for composing asynchronous and event-based programs using observable sequences. It provides features for concurrency, request management, data flow manipulation, and error handling. RxJava uses streams and new objects like Schedulers, Subscriptions, and Subjects. It can be used with techniques like retained fragments, cached observables, binding to lifecycles, and services to handle configuration changes and loading data.
The document discusses the Observer pattern and RxJava. RxJava allows for concurrency, data flow manipulation, and error handling through its use of observables and subscribers. It provides links to documentation on RxJava operators and a blog post that helps explain RxJava fundamentals.
This document discusses Spotify's transition to a "consistent, thin, and dumb" approach to app development. It summarizes Spotify's user and song numbers, the challenges of their previous iOS client, and their shift to a backend-driven model with modular organization. This allows for innovation, scaling, and a unified user experience across platforms through frameworks like GLUE. The document endorses frameworks as "machines" and sharing knowledge and success.
The document summarizes the architectural changes made to the Wunderlist app between versions 2 and 3. Version 3 was completely redesigned with a modular layered architecture that is highly decoupled, enables real-time syncing, and is easier to maintain, test, and adapt compared to the previous monolithic structure. The key layers include presentation, sync, SDK, and model layers with defined boundaries and dependencies between the layers.
The document discusses SoundCloud's approach to mobile testing, including:
- Engineers write unit and UI tests which are run continuously after each code change. Manual testing is also done before releases.
- A test runner service manages test execution across devices in parallel to improve efficiency compared to relying solely on Jenkins.
- An IntelliJ plugin was created to allow testing directly from the IDE for local development, integrating with the test runner service.
The document discusses the VIPER architecture pattern for structuring iOS applications. It begins by introducing the key components of a VIPER module: the View, Presenter, Interactor, Router, and Entity. It then provides examples of how each component is responsible for lifecycle management, event handling, data validation, routing, and other tasks. The document argues that VIPER increases testability, modularity, and code quality of iOS apps. It also promotes open sourcing example VIPER code on GitHub to help disseminate knowledge of this architecture.
MBLTDev15: Anna Mikhina, Maxim Evdokimov, Tinkoff Bank e-Legion
This document discusses working on errors and testing. It focuses on improving performance by identifying mistakes, analyzing what caused them, and learning from the experience to do better in the future. The goal is to enhance skills and knowledge through reflection on past weaknesses or issues uncovered by assessment.
5. Class
Class sampleClass1 = [ELSample class];
Class sampleClass2 = NSClassFromString(@"ELSample");
#import <objc/runtime.h>
!
Class sampleClass3 = objc_getClass(“ELSample");
Class sampleClass4 = objc_lookUpClass(“ELSample");
7. Property attributes
char const *attributesString = property_getAttributes(property);
NSLog(@"%s %s", propertyName, attributesString);
Output:
values T@"NSArray",&,N,V_values
valid Tc,N,GisValid,SsetValidCustom:,Vivar_valid
Code
Meaning
T
type (c - char, @ - id)
N
nonatomic
G
getter selector
S
setter selector
V
ivar name
&
strong/retain
More info
8. Property setter
/**
* @return The value string of the attribute attributeName if it exists in
* property, nil otherwise.
*/
!
char *property_copyAttributeValue(objc_property_t property,
const char *attributeName)
char *setterAttributeValue = property_copyAttributeValue(property, "S");
if (NULL == setterAttributeValue) {
"set" + capitalize(property_getName(property)) + ":"
}
// do not forget!
free(setterAttributeValue);
9. Method invocation
id objc_msgSend(id self, SEL _cmd, ...)
ELSample *sample = [ELSample new];
sample.valid = YES;
[sample setValidCustom:YES];
objc_msgSend(sample, @selector(setValidCustom:), YES);
id objc_msgSend(id self, SEL _cmd, ...)
{
IMP methodFunction = [[self class] methodForSelector:_cmd];
return methodFunction(self, _cmd, ...);
}
10. Method
Method *class_copyMethodList(Class cls, unsigned int *outCount)
!
Method class_getInstanceMethod(Class cls, SEL name)
!
Method class_getClassMethod(Class cls, SEL name)
IMP method_getImplementation(Method m)
!
/**
* @return The previous implementation of the method.
*/
IMP method_setImplementation(Method m, IMP imp)
11. Replacing method implementation
IMP method_setImplementation(Method m, IMP imp)
@interface Sample : NSObject
- (id)swizzleMe:(NSInteger)arg;
@end
Method method = class_getInstanceMethod(class, @selector(swizzleMe:));
typedef id (*IMP)(id, SEL, ...);
id SwizzleFunction(id self, SEL _cmd, NSInteger arg)
{
return @(arg+5);
}
!
method_setImplementation(method, (IMP)SwizzleFunction);
12. Blocks
id(^block)(id, id) = ^id(id self, id arg) {
NSLog(@"arg: %@", arg);
return nil;
};
IMP blockImp = imp_implementationWithBlock(block);
Block can capture original IMP to call it later.
19. Replace the class
Class object_setClass(id obj, Class cls)
NSNumber *number = [NSNumber numberWithDouble:5.1f];
!
Class class = [number class];
NSLog(@"number: %@ %@ %p", number, class, (__bridge void *)number);
// number: 5.099999904632568 __NSCFNumber 0x8d464c0
!
object_setClass(number, [NSObject class]);
NSLog(@"number: %@", number);
// number: <NSObject: 0x8d464c0>
object_setClass(number, class);
NSLog(@"number: %@", number);
// number: 5.099999904632568
20. NSProxy
“… Subclasses of NSProxy can be used to
implement transparent distributed messaging…”
Some people, when confronted with a
problem, think "I know, I'll use NSProxy." Now
they have two problems.