Objective-C Crash Course for Web DevelopersJoris Verbogt
These are the slides of my SXSW 2010 Objective-C Crash Course for Web Developers.
The code samples (and the keynote document) can also be downloaded from http://workshop.verbogt.nl/
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Domenic Denicola
This talk takes a deep dive into asynchronous programming patterns and practices, with an emphasis on the promise pattern.
We go through the basics of the event loop, highlighting the drawbacks of asynchronous programming in a naive callback style. Fortunately, we can use the magic of promises to escape from callback hell with a powerful and unified interface for async APIs. Finally, we take a quick look at the possibilities for using coroutines both in current and future (ECMAScript Harmony) JavaScript.
An introductory presentation I'm doing at my workplace for other developers. This is geared toward programmers that are very new to javascript and covers some basics, but focuses on Functions, Objects and prototypal inheritance ideas.
This was a talk given at HTML5DevConf SF in 2015.
Ever wanted to write your own Browserify or Babel? Maybe have an idea for something new? This talk will get you started understanding how to use a JavaScript AST to transform and generate new code.
Objective-C Crash Course for Web DevelopersJoris Verbogt
These are the slides of my SXSW 2010 Objective-C Crash Course for Web Developers.
The code samples (and the keynote document) can also be downloaded from http://workshop.verbogt.nl/
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Domenic Denicola
This talk takes a deep dive into asynchronous programming patterns and practices, with an emphasis on the promise pattern.
We go through the basics of the event loop, highlighting the drawbacks of asynchronous programming in a naive callback style. Fortunately, we can use the magic of promises to escape from callback hell with a powerful and unified interface for async APIs. Finally, we take a quick look at the possibilities for using coroutines both in current and future (ECMAScript Harmony) JavaScript.
An introductory presentation I'm doing at my workplace for other developers. This is geared toward programmers that are very new to javascript and covers some basics, but focuses on Functions, Objects and prototypal inheritance ideas.
This was a talk given at HTML5DevConf SF in 2015.
Ever wanted to write your own Browserify or Babel? Maybe have an idea for something new? This talk will get you started understanding how to use a JavaScript AST to transform and generate new code.
JavaScript has some stunning features like Closures, Prototype etc. which can help to improve the readability and maintainability of the code. However, it is not easy for inexperienced developer to consume and apply those features in day to day coding. The purpose of the presentation ‘Advanced JavaScript’ is to help a reader easily understand the concept and implementation of some advanced JavaScript features.
Love it or hate it, JavaScript is playing an increasingly important role in the next generation of web and mobile apps. As code continues to move from the server to the client, JavaScript is being used to do more than simple HTML manipulation. Be prepared for this transition and make sure the JavaScript you write is optimized and ready to perform on desktops and devices! In this session, you will learn ten practical tips that you can use today to write faster, more maintainable, memory friendly JavaScript.
Ten useful JavaScript tips & best practicesAnkit Rastogi
In this presentation there are ten useful JavaScript techniques which can be included in your application easily with less friction along with some AngularJs tips and best practices as a bonus. These tips and best practices are accompanied by examples & will cover script loading, design pattern, performance optimization and other areas.
Since best practices are very subjective topics, proper benchmarking needs to be done.
In JS: CLASS <=> Constructor FN
new FN() => FN() { this }
FN = CLASS (FN = FN, FN = DATA)
Objects
Prototype / __proto__
Inheritence
Rewriting / Augmenting
built in objects
This is a presentation for a workshop on understanding common JavaScript concepts and techniques by actually implementing a bare basic jQuery library of own.
Performance Optimization and JavaScript Best PracticesDoris Chen
Performance optimization and JavaScript best practices tips are discussed in the talk. Here are some of the tips:
Put stylesheets at the top (css)
Move scripts to the bottom (javascript)
Provide a clean separation of content, CSS, and JavaScript
De-reference unused objects
Think Asynchronous
Working with Objects
Defer Loading Resources
Use JSLint -- Code Quality Tool
Reduce the size of JavaScript file
gzip
General JavaScript Coding Best Practices
Use === Instead of ==
Eval = Bad
Don’t Use Short-Hand
Reduce Globals: Namespace
Don't Pass a String to "SetInterval" or "SetTimeOut"
Use {} Instead of New Object()
Use [] Instead of New Array()
Powerful JavaScript Tips and Best PracticesDragos Ionita
Javascript Best Practices, IIFE, Immediately invoked function expressions, typeof, instanceof, constructor, random items from an array, generate an array of numbers, append an array to another array, is a number, is an array, remove an item from an array
Building High Perf Web Apps - IE8 FirestarterMithun T. Dhar
Video recordings of this session can be found here:
1. http://channel9.msdn.com/tags/IE%208%20Firestarter - (Developer)
2. http://edge.technet.com/Tags/IE+8+Firestarter/ - (IT Pro's)
If you need to download this file, or need more infomation contact Mithun Dhar via http://blogs.msdn.com/mithund
Many people consider the Objective-C a verbose language, with a cumbersome syntax, whilst it is actually a very simple language with few rules. Year after year the language has been changed many times with small but very important improvements. Particularly in the last two years many features have been added to modernize the language. In this talk you will see all the latest news and a series of best practices to improve the quality of the code
Updated version using Swift 3 is available here:
https://www.slideshare.net/bobmccune/quartz-2d-with-swift-3/
Presentation by Bob McCune of TapHarmonic detailing how to use the Quartz framework to perform 2D drawing on the iOS platform. Quartz Demos:
https://github.com/tapharmonic/QuartzDemos
JavaScript has some stunning features like Closures, Prototype etc. which can help to improve the readability and maintainability of the code. However, it is not easy for inexperienced developer to consume and apply those features in day to day coding. The purpose of the presentation ‘Advanced JavaScript’ is to help a reader easily understand the concept and implementation of some advanced JavaScript features.
Love it or hate it, JavaScript is playing an increasingly important role in the next generation of web and mobile apps. As code continues to move from the server to the client, JavaScript is being used to do more than simple HTML manipulation. Be prepared for this transition and make sure the JavaScript you write is optimized and ready to perform on desktops and devices! In this session, you will learn ten practical tips that you can use today to write faster, more maintainable, memory friendly JavaScript.
Ten useful JavaScript tips & best practicesAnkit Rastogi
In this presentation there are ten useful JavaScript techniques which can be included in your application easily with less friction along with some AngularJs tips and best practices as a bonus. These tips and best practices are accompanied by examples & will cover script loading, design pattern, performance optimization and other areas.
Since best practices are very subjective topics, proper benchmarking needs to be done.
In JS: CLASS <=> Constructor FN
new FN() => FN() { this }
FN = CLASS (FN = FN, FN = DATA)
Objects
Prototype / __proto__
Inheritence
Rewriting / Augmenting
built in objects
This is a presentation for a workshop on understanding common JavaScript concepts and techniques by actually implementing a bare basic jQuery library of own.
Performance Optimization and JavaScript Best PracticesDoris Chen
Performance optimization and JavaScript best practices tips are discussed in the talk. Here are some of the tips:
Put stylesheets at the top (css)
Move scripts to the bottom (javascript)
Provide a clean separation of content, CSS, and JavaScript
De-reference unused objects
Think Asynchronous
Working with Objects
Defer Loading Resources
Use JSLint -- Code Quality Tool
Reduce the size of JavaScript file
gzip
General JavaScript Coding Best Practices
Use === Instead of ==
Eval = Bad
Don’t Use Short-Hand
Reduce Globals: Namespace
Don't Pass a String to "SetInterval" or "SetTimeOut"
Use {} Instead of New Object()
Use [] Instead of New Array()
Powerful JavaScript Tips and Best PracticesDragos Ionita
Javascript Best Practices, IIFE, Immediately invoked function expressions, typeof, instanceof, constructor, random items from an array, generate an array of numbers, append an array to another array, is a number, is an array, remove an item from an array
Building High Perf Web Apps - IE8 FirestarterMithun T. Dhar
Video recordings of this session can be found here:
1. http://channel9.msdn.com/tags/IE%208%20Firestarter - (Developer)
2. http://edge.technet.com/Tags/IE+8+Firestarter/ - (IT Pro's)
If you need to download this file, or need more infomation contact Mithun Dhar via http://blogs.msdn.com/mithund
Many people consider the Objective-C a verbose language, with a cumbersome syntax, whilst it is actually a very simple language with few rules. Year after year the language has been changed many times with small but very important improvements. Particularly in the last two years many features have been added to modernize the language. In this talk you will see all the latest news and a series of best practices to improve the quality of the code
Updated version using Swift 3 is available here:
https://www.slideshare.net/bobmccune/quartz-2d-with-swift-3/
Presentation by Bob McCune of TapHarmonic detailing how to use the Quartz framework to perform 2D drawing on the iOS platform. Quartz Demos:
https://github.com/tapharmonic/QuartzDemos
Presentation by Bob McCune of TapHarmonic detailing how to use the Quartz (CoreGraphics) framework with Swift 3.
Sample code available here: https://github.com/tapharmonic/QuartzDemosSwift
Slides for my Master Video session at Renaissance 2014. This session provided a high-level overview of some of AV Foundation's video playback and editing capabilities.
The demo app for this talk can be found at:
https://github.com/tapharmonic/AVFoundationEditor
Designing better user interfaces sets out to teach interface design by talking through concrete examples: what works, what doesn’t work. A good interface consists of a thousand details done right. This presentation is all about those details.
So, you're a developer, but you have never worked with iOS? In this session, Ardeleanu will provide a head start on how to plan, build, debug and release iOS 7 apps. The talk will cover a wide range of topics, including: the App Store ecosystem; the nature of an app; iOS 7's new UI and how to migrate from iOS 6; interface design; dev tools (Xcode – IDE, Simulator, Instruments – docs, etc); design patterns; debugging and optimisation; App Store and ad-hoc distribution; and what makes an app successfully.
The AV Foundation has grown from a simple audio player quietly added in iPhone OS 2.2 to an extraordinarily ambitious media-creation framework in iOS 4. The latest version provides highly-customizable audio and video capture, deep support for editing and Core Animation-based effects, and export. It is far more comprehensive than nearly any other platform's media framework, mobile or desktop. As a developer, this gives you incredible power… and one heck of a learning curve. In this session, we will take a ground-up look at AV Foundation, starting with its core concepts and patterns, and moving through its most practical and powerful capabilities. Along the way, we'll see how AV Foundation works with iOS' other media APIs -- Core Audio, Media Player, and Core Media -- and how it aggressively uses new iOS 4 programming paradigms like blocks and Grand Central Dispatch. Attendees will come away understanding the straight-arrow paths to AV Foundation's most important features like capture, editing, and export, and how its pieces might be combined in interesting ways to create even more powerful media applications.
This presentation reviews the various approaches you can take to creating animations in your iOS apps.
It discusses UIKit animations, including curling pages up (as in the Maps app), flipping back and forth (as in the Stocks app) and image view animations.
It also describes Core Animation, including its implicit animations that occur when you change the value of certain animatable properties, as well as how to create explicit animations.
Slides for the 1st lecture on mobile development (dedicated to iOS) at the Faculty of Mathematics and Physics at the Charles University in Prague.
Course page: http://www.inmite.eu/en/talks/mff-2012
iOS development Crash course in how to build an native application for iPhone.
i will be start from beginning till publishing on Apple Store step by step.
this session # 2
Objective-C is a Smalltalk-like Object-Oriented layer on top of the C language. It is the official language of OS X and iOS. Assuming you have a background in Object-Oriented Programming and a basic understanding of the C language or syntax, this talk will cover everything you need to know about Objective-C. By the end of the talk, you will understand how to make and use your own objects, the Foundation Framework and the data structures it provides, and the Objective-C specific language constructs and syntactic-sugar.
Session 2 of Objective-C for the Irving iOS Jumpstart meetup. This evening we learned about creating UITableView's and programmatically setting the contents of their UITableViewCell's.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
I have heard many times that architecture is not important for the front-end. Also, many times I have seen how developers implement features on the front-end just following the standard rules for a framework and think that this is enough to successfully launch the project, and then the project fails. How to prevent this and what approach to choose? I have launched dozens of complex projects and during the talk we will analyze which approaches have worked for me and which have not.
3. Objective-C
The old new hotness
• Strict superset of ANSI C
• Object-oriented extensions
• Additional syntax and types
• Native Mac & iOS development language
• Flexible typing
• Simple, expressive syntax
• Dynamic runtime
Tuesday, August 10, 2010
4. Why Use Objective-C?
No Java love from Apple?
• Key to developing for Mac & iOS platforms
• Performance
• Continually optimized runtime environment
• Can optimize down to C as needed
• Memory Management
• Dynamic languages provide greater flexibility
• Cocoa APIs rely heavily on these features
Tuesday, August 10, 2010
5. Java Developer’s Concerns
Ugh, didn’t Java solve all of this stuff
• Pointers
• Memory Management
• Preprocessing & Linking
• No Namespaces
• Prefixes used to avoid collisions
• Common Prefixes: NS, UI, CA, MK, etc.
Tuesday, August 10, 2010
7. Classes
• Classes define the blueprint for objects.
• Objective-C class definitions are separated
into an interface and an implementation.
• Usually defined in separate .h and .m files
•Defines the •Defines the actual
programming implementation
interface code
•Defines the •Defines one or
object's instance more initializers
variable to properly
initialize and
object instance
Tuesday, August 10, 2010
8. Defining the class interface
@interface BankAccount : NSObject {
float accountBalance;
NSString *accountNumber;
}
- (float)withDraw:(float)amount;
- (void)deposit:(float)amount;
@end
Tuesday, August 10, 2010
9. Defining the class interface
@interface BankAccount : NSObject {
float accountBalance;
NSString *accountNumber;
}
- (float)withDraw:(float)amount;
- (void)deposit:(float)amount;
@end
Tuesday, August 10, 2010
10. Defining the class interface
@interface BankAccount : NSObject {
float accountBalance;
NSString *accountNumber;
}
- (float)withDraw:(float)amount;
- (void)deposit:(float)amount;
@end
Tuesday, August 10, 2010
11. Defining the class interface
@interface BankAccount : NSObject {
float accountBalance;
NSString *accountNumber;
}
- (float)withDraw:(float)amount;
- (void)deposit:(float)amount;
@end
Tuesday, August 10, 2010
12. Defining the class interface
@interface BankAccount : NSObject {
float accountBalance;
NSString *accountNumber;
}
- (float)withDraw:(float)amount;
- (void)deposit:(float)amount;
@end
Tuesday, August 10, 2010
13. Defining the class interface
@interface BankAccount : NSObject {
float accountBalance;
NSString *accountNumber;
}
- (float)withDraw:(float)amount;
- (void)deposit:(float)amount;
@end
Tuesday, August 10, 2010
19. Creating Objects
From blueprint to reality
• No concept of constructors in Objective-C
• Regular methods create new instances
• Allocation and initialization are performed
separately
• Provides flexibility in where an object is allocated
• Provides flexibility in how an object is initialized
Java
BankAccount account = new BankAccount();
Objective C
BankAccount *account = [[BankAccount alloc] init];
Tuesday, August 10, 2010
20. Creating Objects
• NSObject defines class method called alloc
• Dynamically allocates memory for object
• Returns new instance of receiving class
BankAccount *account = [BankAccount alloc];
• NSObject defines instance method init
• Implemented by subclasses to initialize instance after memory
for it has been allocated
• Subclasses commonly define several initializers
account = [account init];
• alloc and init calls are almost always nested into single line
BankAccount *account = [[BankAccount alloc] init];
Tuesday, August 10, 2010
21. Methods
• Classes can define both class and instance methods
• Methods are always public.
• “Private” methods defined in implementation
• Class methods (prefixed with +):
• Define behaviors associated with class, not particular
instance
• No access to instance variables
• Instance methods (prefixed with -)
• Define behaviors specific to particular instance
• Manage object state
• Methods invoked by passing messages...
Tuesday, August 10, 2010
22. Messages
Speaking to objects
• Methods are invoked by passing messages
• Done indirectly. We never directly invoke
methods
• Messages dynamically bound to method
implementations at runtime
• Dispatching handled by runtime environment
• Simple messages take the form:
•
[object message];
• Can pass one or more arguments:
•
[object messageWithArg1:arg1 arg2:arg2];
Tuesday, August 10, 2010
23. self and super
• Methods have implicit reference to owning
object called self (similar to Java’s this)
• Additionally have access to superclass
methods using super
-(id)init {
if (self = [super init]) {
// do initialization
}
return self;
}
Tuesday, August 10, 2010
24. Invoking methods in Java
Map person = new HashMap();
person.put("name", "Joe Smith");
String address = "123 Street";
String house = address.substring(0, 3);
person.put("houseNumber", house);
List children = Arrays.asList("Sue", "Tom");
person.put("children", children);
Tuesday, August 10, 2010
27. Memory Management
Dude, where’s my Garbage Collection?
• Garbage collection available for Mac apps (10.5+)
• Use it if targeting 10.5+!
• Use explicit memory management if targeting
<= 10.4
• No garbage collection on iOS due to performance
concerns.
• Memory managed using simple reference counting
mechanism:
• Higher level abstraction than malloc / free
• Straightforward approach, but must adhere to
conventions and rules
Tuesday, August 10, 2010
28. Memory Management
Reference Counting
• Objective-C objects are reference counted
• Objects start with reference count of 1
• Increased with retain
• Decreased with release, autorelease
• When count equals 0, runtime invokes dealloc
1 2 1 0
alloc retain release release
Tuesday, August 10, 2010
29. Memory Management
Understanding the rules
• Implicitly retain any object you create using:
Methods starting with "alloc", "new", or contains "copy"
e.g alloc, allocWithZone, newObject, mutableCopy,etc.
• If you've retained it, you must release it
• Many objects provide convenience methods
that return an autoreleased reference.
• Holding object reference from these
methods does not make you the retainer
• However, if you retain it you need an
offsetting release or autorelease to free it
Tuesday, August 10, 2010
44. Protocols
Java’s Interface done Objective-C style
• List of method declarations
• Not associated with a particular class
• Conformance, not class, is important
• Useful in defining:
• Methods that others are expected to
implement
• Declaring an interface while hiding its particular
class
• Capturing similarities among classes that aren't
hierarchically related
Tuesday, August 10, 2010
45. Protocols
NSCoding NSObject NSCoding
Person Account
CheckingAccount SavingAccount
Tuesday, August 10, 2010
46. Defining a Protocol
NSCoding from Foundation Framework
Objective-C equivalent to java.io.Externalizable
@protocol NSCoding
- (void)encodeWithCoder:(NSCoder *)aCoder;
- (id)initWithCoder:(NSCoder *)aDecoder;
@end
Tuesday, August 10, 2010
47. Adopting a Protocol
@interface Person : NSObject <NSCoding> {
NSString *name;
NSString *street;
NSString *city, *state, *zip;
}
// method declarations
@end
Tuesday, August 10, 2010
48. Conforming to a Protocol
Partial implementation of conforming Person class
@implementation Person
-(id)initWithCoder:(NSCoder *)coder {
if (self = [super init]) {
name = [coder decodeObjectForKey:@"name"];
[name retain];
}
return self;
}
-(void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:name forKey:@"name"];
}
@end
Tuesday, August 10, 2010
49. @required and @optional
• Protocols methods are required by default
• Can be relaxed with @optional directive
@protocol SomeProtocol
- (void)requiredMethod;
@optional
- (void)anOptionalMethod;
- (void)anotherOptionalMethod;
@required
- (void)anotherRequiredMethod;
@end
Tuesday, August 10, 2010
51. Categories
Extending Object Features
• Add new methods to existing classes
• Alternative to subclassing
• Defines new methods and can override existing
• Does not define new instance variables
• Becomes part of the class definition
• Inherited by subclasses
• Can be used as organizational tool
• Often used in defining "private" methods
Tuesday, August 10, 2010
52. Using Categories
Interface
@interface NSString (Extensions)
-(NSString *)trim;
@end
Implementation
@implementation NSString (Extensions)
-(NSString *)trim {
NSCharacterSet *charSet =
[NSCharacterSet whitespaceAndNewlineCharacterSet];
return [self stringByTrimmingCharactersInSet:charSet];
}
@end
Usage
NSString *string = @" A string to be trimmed ";
NSLog(@"Trimmed string: '%@'", [string trim]);
Tuesday, August 10, 2010
53. Class Extensions
Unnamed Categories
• Objective-C 2.0 adds ability to define
"anonymous" categories
• Category is unnamed
• Treated as class interface continuations
• Useful for implementing required "private" API
• Compiler enforces methods are implemented
Tuesday, August 10, 2010
54. Class Extensions
Example
@interface Person : NSObject {
NSString *name;
}
-(NSString *)name;
@end
Tuesday, August 10, 2010
55. Class Extensions
Example
@interface Person ()
-(void)setName:(NSString *)newName;
@end
@implementation Person
- (NSString *)name {
return name;
}
- (void)setName:(NSString *)newName {
name = newName;
}
@end
Tuesday, August 10, 2010
57. Objective-C
Summary
• Fully C, Fully Object-Oriented
• Powerful dynamic runtime
• Objective-C 2.0 added many useful new
features
• Garbage Collection for Mac OS X apps
• Properties, Improved Categories & Protocols
• Objective-C 2.1 continues its evolution:
• Blocks (Closures)
• Synthesize by default for properties
Tuesday, August 10, 2010