The document provides notes from a CS193p class on Wednesday, April 7, 2010. It covers topics including announcements, communication methods, Foundation frameworks like NSArray and NSDictionary, Objective-C concepts like protocols and delegates, memory management using reference counting, and a demo of an MVC collector app. It also lists the homework assignment to add variable support to the CalculatorBrain using Foundation classes and improve memory management.
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legione-Legion
Цель доклада — вдохновить разработчиков на более глубокое изучение возможностей Objective-C Runtime, показать способы исследования системы, воодушевить аудиторию на эксперименты.
В докладе показаны несколько примеров использования Objective-C Runtime для решения нетипичных задач. Первый пример - реализация простого KVO своими руками тремя способами. Вторым примером показана полезность исследования приватных классов. Рассказано, как во время работы программы получить информацию о протянутых IBOutlet и IBAction в xib и storyboard. В каждом примере присутствуют особенности реализации, на которых сделан акцент и показаны варианты решения или обхода.
This document provides an overview of Objective-C for Java developers. It discusses that Objective-C is the primary language for developing Mac and iOS apps due to its performance and ability to interface with Cocoa frameworks. It describes Objective-C classes as having interface and implementation definitions separated into .h and .m files. Methods are defined and called by passing messages to objects, with dispatch handled dynamically at runtime. The document also covers creating and working with Objective-C objects by allocating and initializing them.
The document discusses the history and key concepts of Objective-C and its runtime. It originated from Brad Cox and Tom Love at ITT Corp in 1981, combining Smalltalk and C. An object contains an isa pointer that points to its class definition. Messaging allows sending commands to objects by name and is the fundamental operation in Objective-C, where methods are just functions that receive a message.
Week 06 Modular Javascript_Brandon, S. H. WuAppUniverz Org
This document discusses reusable code at clients using layouts and the model-view-controller (MVC) pattern. It covers object-oriented JavaScript for writing reusable classes. It also discusses modular GUI development with components, containers, and layouts to build assemblable user interfaces. Finally, it introduces client-side MVC to help maintain large JavaScript projects by separating concerns into models, views, and controllers.
The document discusses pointers and objects in object-oriented programming. It explains that pointers can point to objects, and that the new operator allocates memory for an object and invokes its constructor. It also describes using the delete operator to release the memory of an object. Additionally, it covers using pointers to objects to create linked lists of objects, and discusses different approaches like adding a pointer to the class, deriving a new class, or using a separate node class.
The document provides a summary of XPath and XSLT functions and operators. It lists XPath axes, node tests, and location paths. It also outlines XSLT elements for templates, variables, parameters, output, and other transformations. Key functions covered include node-set, last, position, count, id, local-name, namespace-uri, name, string, concat, and boolean.
This document is a presentation about the JavaScript programming language. It discusses JavaScript syntax, values, data types, statements, functions, objects, arrays, and other core concepts. It also covers best practices for JavaScript development like modularity, encapsulation, and using tools like debuggers, minifiers, and build tools. The presentation provides an overview of the essential elements of JavaScript.
This document provides an overview of object-oriented programming concepts in JavaScript. It defines key terms like class, method, object, and constructor. It explains that in JavaScript, functions act as classes that can be used to create object instances. Constructors are called when an object is created to initialize its properties. The document provides examples of defining a class and creating multiple instance objects that each have their own copies of instance variables. It also discusses the object lifecycle of creation, use, and disposal in JavaScript.
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legione-Legion
Цель доклада — вдохновить разработчиков на более глубокое изучение возможностей Objective-C Runtime, показать способы исследования системы, воодушевить аудиторию на эксперименты.
В докладе показаны несколько примеров использования Objective-C Runtime для решения нетипичных задач. Первый пример - реализация простого KVO своими руками тремя способами. Вторым примером показана полезность исследования приватных классов. Рассказано, как во время работы программы получить информацию о протянутых IBOutlet и IBAction в xib и storyboard. В каждом примере присутствуют особенности реализации, на которых сделан акцент и показаны варианты решения или обхода.
This document provides an overview of Objective-C for Java developers. It discusses that Objective-C is the primary language for developing Mac and iOS apps due to its performance and ability to interface with Cocoa frameworks. It describes Objective-C classes as having interface and implementation definitions separated into .h and .m files. Methods are defined and called by passing messages to objects, with dispatch handled dynamically at runtime. The document also covers creating and working with Objective-C objects by allocating and initializing them.
The document discusses the history and key concepts of Objective-C and its runtime. It originated from Brad Cox and Tom Love at ITT Corp in 1981, combining Smalltalk and C. An object contains an isa pointer that points to its class definition. Messaging allows sending commands to objects by name and is the fundamental operation in Objective-C, where methods are just functions that receive a message.
Week 06 Modular Javascript_Brandon, S. H. WuAppUniverz Org
This document discusses reusable code at clients using layouts and the model-view-controller (MVC) pattern. It covers object-oriented JavaScript for writing reusable classes. It also discusses modular GUI development with components, containers, and layouts to build assemblable user interfaces. Finally, it introduces client-side MVC to help maintain large JavaScript projects by separating concerns into models, views, and controllers.
The document discusses pointers and objects in object-oriented programming. It explains that pointers can point to objects, and that the new operator allocates memory for an object and invokes its constructor. It also describes using the delete operator to release the memory of an object. Additionally, it covers using pointers to objects to create linked lists of objects, and discusses different approaches like adding a pointer to the class, deriving a new class, or using a separate node class.
The document provides a summary of XPath and XSLT functions and operators. It lists XPath axes, node tests, and location paths. It also outlines XSLT elements for templates, variables, parameters, output, and other transformations. Key functions covered include node-set, last, position, count, id, local-name, namespace-uri, name, string, concat, and boolean.
This document is a presentation about the JavaScript programming language. It discusses JavaScript syntax, values, data types, statements, functions, objects, arrays, and other core concepts. It also covers best practices for JavaScript development like modularity, encapsulation, and using tools like debuggers, minifiers, and build tools. The presentation provides an overview of the essential elements of JavaScript.
This document provides an overview of object-oriented programming concepts in JavaScript. It defines key terms like class, method, object, and constructor. It explains that in JavaScript, functions act as classes that can be used to create object instances. Constructors are called when an object is created to initialize its properties. The document provides examples of defining a class and creating multiple instance objects that each have their own copies of instance variables. It also discusses the object lifecycle of creation, use, and disposal in JavaScript.
1. JavaScript is a scripting language used in web browsers. It was originally created to make web pages more interactive and dynamic.
2. The document discusses the history and evolution of JavaScript, including its origins from Scheme and Java, standardization by ECMA, and adoption by major browsers.
3. Key concepts covered include JavaScript objects, functions, and closures. Objects are fundamental data types in JavaScript along with primitives like strings and numbers. Functions are objects that can be assigned to variables or passed as arguments. Closures allow functions to access variables from outer scopes.
- Data structures allow for efficient processing and organization of large volumes of data. They define logical relationships between related data elements and how operations like storage, retrieval, and access are carried out on the data.
- Common data structures include arrays, lists, stacks, queues, trees, graphs, dictionaries, maps, hash tables, sets, and lattices. Linear data structures like arrays and lists store elements in a linear order, while non-linear structures like trees and graphs have more complex relationships between elements.
- Linked lists are a data structure where each element contains a link to the next element, rather than using contiguous memory locations. This allows for more flexible insertion and deletion than arrays. Doubly linked lists add a link to
The document discusses memory management in Objective-C for iPhone applications. It covers key concepts like reference counting, object ownership, autorelease pools, and common mistakes to avoid. The document also provides examples of proper memory management techniques like retaining objects, releasing objects, and using autorelease to avoid memory leaks.
(3) cpp abstractions more_on_user_defined_typesNico Ludwig
The document discusses C++ abstractions related to managing object lifetimes and dynamic memory. It introduces the concepts of creating objects on the freestore using new/delete rather than malloc/free, and how destructors allow objects to automatically free resources when going out of scope through RAII (Resource Acquisition Is Initialization). This avoids issues like forgetting to free memory. Copies of objects can also be avoided by passing references instead of values.
The document outlines various data persistence techniques in iOS, including NSUserDefaults for simple storage, NSCache for caching objects in memory, archiving custom objects using NSCoding, and Core Data as an efficient framework for managing object persistence with features like change tracking and relationships between entities. Code examples are provided to demonstrate implementing these techniques.
The document discusses data structures and provides details about various data structures like arrays, linked lists, stacks, queues, trees and graphs. It explains the concepts of abstract data types, linear and non-linear data structures. Key details about arrays, linked lists and their limitations are provided. Implementation of singly linked lists using C language is demonstrated through functions like creation, insertion, deletion and traversal of nodes.
XSLT 1 and XPath Quick Reference (from mulberrytech.com)FrescatiStory
This document provides summaries of key concepts in XPath and XSLT including:
- XPath location paths for selecting nodes
- XPath operators for comparing and combining expressions
- XSLT functions for manipulating nodes and values
- Common XSLT elements for transforming XML documents like apply-templates, template, and value-of.
The document discusses ActiveSupport::Concern, a module in Ruby on Rails that provides a way to write reusable modules. It handles dependencies between modules and includes common functionality like scopes. ActiveSupport also allows pluggable JSON backends for improved performance and includes helper methods like presence that simplify checking for blank values. Classes can also define inheritable class attributes using ClassAttribute.
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.
1. Constructors are special methods used to initialize objects when they are created. Even if a constructor is not explicitly defined, a default constructor is provided.
2. The process of creating an object involves allocating memory using the new keyword and initializing the object by calling a constructor.
3. A default constructor has public accessibility, the same name as the class, no return type, expects no arguments, and initializes all fields to default values like 0, false, or null.
What is a Blockchain?
Why do we need such technology? What can it do for us…
How does Blockchain work…
Python Implementation of a Blockchain.
Intro to IBM Hyperledger.
Use case scenarios and real world usage, besides digital money .
EnContRA is a framework for content-based retrieval approaches and applications. It provides modularity, ease of use, and fast development of new approaches. EnContRA supports indexing, feature extraction, search/retrieval algorithms, and extensible query processing for different multimedia types including images, drawings, 3D objects, and audio. Typical applications are built using EnContRA modules including descriptors, indexing structures, and search algorithms. The document provides examples of building simple and more complex image retrieval applications using EnContRA.
Anonymous classes in PHP 7 allow for the definition of classes without specifying a name. This document discusses what anonymous classes are, how to use them, and some limitations. Key points include: anonymous classes can implement interfaces and extend classes, inherit traits, and be used for test mocking and one-off objects due to their dynamic nature. However, they cannot be serialized, have limited scoping, and lack documentation.
This document discusses two approaches for connecting Node.js applications to MySQL databases: 1) Using a JavaScript MySQL client library like mysql (node-mysql) and 2) Using a common relational database framework for Node.js connections called node-db (db-mysql). It provides instructions for installing db-mysql and an example of connecting to a database and running queries.
The document introduces a plan to cover Java and Android basics, Android UI topics, and Android in action over three parts. Part I provides an introduction to Java concepts like the JVM, garbage collection, threads, and an overview of the Android architecture and building blocks. It also demonstrates an NDK example. The document outlines the topics that will be covered in each part of the training.
The document provides instructions on how to implement undo and redo functionality using key-value observing in Cocoa. It explains that KVO allows objects to automatically receive notifications when observed properties change. It also discusses registering observers for specific properties, and handling the notifications in the observer. The document shows examples of implementing both simple and invocation-based undo methods using KVO.
The document discusses file systems and how they work at different layers, including the semantic layer which maps user-friendly names to unique keys, the object layer which defines different data structure types to store objects, and the device layer which is responsible for physically storing data on disk using techniques like block allocation and bitmaps. It provides examples of how different types of objects like directories, tables, and records could be implemented and describes the common operations performed at each layer like open, read, write, allocate, and deallocate.
This document provides a summary of utility methods in Prototype.js version 1.6.0.2. It lists methods for working with events, elements, enumerables, documents, strings, forms, positions, and classes.
This document provides an overview of the Yahoo User Interface (YUI) library. It discusses why developers would use YUI and provides examples of common YUI components and methods, including getting started with YUI, the YUI log and dump methods, event handling methods like later() and delegate(), utility methods like mix() and merge(), and the class system including augment() and plug(). It encourages developers to learn more about YUI through its documentation and community resources.
Using Templates to Achieve Awesomer ArchitectureGarann Means
Templates are the best kind of tool: simple to write and implement, but powerful enough to make your architecture slicker and your code leaner. Getting markup out of your Javascript is a huge deal, but templates can help with more than that. They can manage repeated code snippets, allow you to deftly switch states in single page applications, and help keep your code DRY when supporting users with and without Javascript enabled. Using and extending them creatively can make any architecture a little awesomer.
These slides are for beginners wanting to learn Objective-C for the development of iOS of Mac OSX. These slides contain information about the basic datatypes used in the Objective-C development.
{"JSON, Swift and Type Safety" : "It's a wrap"}Anthony Levings
Anthony Levings presented on using enums with associated values to safely parse JSON in Swift and achieve type safety. This approach wraps JSON values as they are parsed to restrict changes of type. It enables compile-time type checking and reduces testing needs compared to approaches that return loose types. Potential challenges include increased build times for large models, but alternative approaches that wrap values on demand may address this.
1. JavaScript is a scripting language used in web browsers. It was originally created to make web pages more interactive and dynamic.
2. The document discusses the history and evolution of JavaScript, including its origins from Scheme and Java, standardization by ECMA, and adoption by major browsers.
3. Key concepts covered include JavaScript objects, functions, and closures. Objects are fundamental data types in JavaScript along with primitives like strings and numbers. Functions are objects that can be assigned to variables or passed as arguments. Closures allow functions to access variables from outer scopes.
- Data structures allow for efficient processing and organization of large volumes of data. They define logical relationships between related data elements and how operations like storage, retrieval, and access are carried out on the data.
- Common data structures include arrays, lists, stacks, queues, trees, graphs, dictionaries, maps, hash tables, sets, and lattices. Linear data structures like arrays and lists store elements in a linear order, while non-linear structures like trees and graphs have more complex relationships between elements.
- Linked lists are a data structure where each element contains a link to the next element, rather than using contiguous memory locations. This allows for more flexible insertion and deletion than arrays. Doubly linked lists add a link to
The document discusses memory management in Objective-C for iPhone applications. It covers key concepts like reference counting, object ownership, autorelease pools, and common mistakes to avoid. The document also provides examples of proper memory management techniques like retaining objects, releasing objects, and using autorelease to avoid memory leaks.
(3) cpp abstractions more_on_user_defined_typesNico Ludwig
The document discusses C++ abstractions related to managing object lifetimes and dynamic memory. It introduces the concepts of creating objects on the freestore using new/delete rather than malloc/free, and how destructors allow objects to automatically free resources when going out of scope through RAII (Resource Acquisition Is Initialization). This avoids issues like forgetting to free memory. Copies of objects can also be avoided by passing references instead of values.
The document outlines various data persistence techniques in iOS, including NSUserDefaults for simple storage, NSCache for caching objects in memory, archiving custom objects using NSCoding, and Core Data as an efficient framework for managing object persistence with features like change tracking and relationships between entities. Code examples are provided to demonstrate implementing these techniques.
The document discusses data structures and provides details about various data structures like arrays, linked lists, stacks, queues, trees and graphs. It explains the concepts of abstract data types, linear and non-linear data structures. Key details about arrays, linked lists and their limitations are provided. Implementation of singly linked lists using C language is demonstrated through functions like creation, insertion, deletion and traversal of nodes.
XSLT 1 and XPath Quick Reference (from mulberrytech.com)FrescatiStory
This document provides summaries of key concepts in XPath and XSLT including:
- XPath location paths for selecting nodes
- XPath operators for comparing and combining expressions
- XSLT functions for manipulating nodes and values
- Common XSLT elements for transforming XML documents like apply-templates, template, and value-of.
The document discusses ActiveSupport::Concern, a module in Ruby on Rails that provides a way to write reusable modules. It handles dependencies between modules and includes common functionality like scopes. ActiveSupport also allows pluggable JSON backends for improved performance and includes helper methods like presence that simplify checking for blank values. Classes can also define inheritable class attributes using ClassAttribute.
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.
1. Constructors are special methods used to initialize objects when they are created. Even if a constructor is not explicitly defined, a default constructor is provided.
2. The process of creating an object involves allocating memory using the new keyword and initializing the object by calling a constructor.
3. A default constructor has public accessibility, the same name as the class, no return type, expects no arguments, and initializes all fields to default values like 0, false, or null.
What is a Blockchain?
Why do we need such technology? What can it do for us…
How does Blockchain work…
Python Implementation of a Blockchain.
Intro to IBM Hyperledger.
Use case scenarios and real world usage, besides digital money .
EnContRA is a framework for content-based retrieval approaches and applications. It provides modularity, ease of use, and fast development of new approaches. EnContRA supports indexing, feature extraction, search/retrieval algorithms, and extensible query processing for different multimedia types including images, drawings, 3D objects, and audio. Typical applications are built using EnContRA modules including descriptors, indexing structures, and search algorithms. The document provides examples of building simple and more complex image retrieval applications using EnContRA.
Anonymous classes in PHP 7 allow for the definition of classes without specifying a name. This document discusses what anonymous classes are, how to use them, and some limitations. Key points include: anonymous classes can implement interfaces and extend classes, inherit traits, and be used for test mocking and one-off objects due to their dynamic nature. However, they cannot be serialized, have limited scoping, and lack documentation.
This document discusses two approaches for connecting Node.js applications to MySQL databases: 1) Using a JavaScript MySQL client library like mysql (node-mysql) and 2) Using a common relational database framework for Node.js connections called node-db (db-mysql). It provides instructions for installing db-mysql and an example of connecting to a database and running queries.
The document introduces a plan to cover Java and Android basics, Android UI topics, and Android in action over three parts. Part I provides an introduction to Java concepts like the JVM, garbage collection, threads, and an overview of the Android architecture and building blocks. It also demonstrates an NDK example. The document outlines the topics that will be covered in each part of the training.
The document provides instructions on how to implement undo and redo functionality using key-value observing in Cocoa. It explains that KVO allows objects to automatically receive notifications when observed properties change. It also discusses registering observers for specific properties, and handling the notifications in the observer. The document shows examples of implementing both simple and invocation-based undo methods using KVO.
The document discusses file systems and how they work at different layers, including the semantic layer which maps user-friendly names to unique keys, the object layer which defines different data structure types to store objects, and the device layer which is responsible for physically storing data on disk using techniques like block allocation and bitmaps. It provides examples of how different types of objects like directories, tables, and records could be implemented and describes the common operations performed at each layer like open, read, write, allocate, and deallocate.
This document provides a summary of utility methods in Prototype.js version 1.6.0.2. It lists methods for working with events, elements, enumerables, documents, strings, forms, positions, and classes.
This document provides an overview of the Yahoo User Interface (YUI) library. It discusses why developers would use YUI and provides examples of common YUI components and methods, including getting started with YUI, the YUI log and dump methods, event handling methods like later() and delegate(), utility methods like mix() and merge(), and the class system including augment() and plug(). It encourages developers to learn more about YUI through its documentation and community resources.
Using Templates to Achieve Awesomer ArchitectureGarann Means
Templates are the best kind of tool: simple to write and implement, but powerful enough to make your architecture slicker and your code leaner. Getting markup out of your Javascript is a huge deal, but templates can help with more than that. They can manage repeated code snippets, allow you to deftly switch states in single page applications, and help keep your code DRY when supporting users with and without Javascript enabled. Using and extending them creatively can make any architecture a little awesomer.
These slides are for beginners wanting to learn Objective-C for the development of iOS of Mac OSX. These slides contain information about the basic datatypes used in the Objective-C development.
{"JSON, Swift and Type Safety" : "It's a wrap"}Anthony Levings
Anthony Levings presented on using enums with associated values to safely parse JSON in Swift and achieve type safety. This approach wraps JSON values as they are parsed to restrict changes of type. It enables compile-time type checking and reduces testing needs compared to approaches that return loose types. Potential challenges include increased build times for large models, but alternative approaches that wrap values on demand may address this.
RubyMotion allows iOS development using the Ruby language instead of Objective-C. It provides a command line toolchain and compiles Ruby code to native iOS apps. While the syntax is Ruby, the underlying classes and objects are still Objective-C/Cocoa. This allows tapping into the full iOS SDK while enjoying Ruby's more succinct syntax. The document provides an example Hello World app and demonstrates how to load images from the camera library using RubyMotion and related libraries like Bubblewrap and RMQ.
This document discusses various data persistence options in iOS, including NSUserDefaults, NSCache, archives using the NSCoding protocol, Core Data, and iCloud. It provides an overview and examples of each technique. NSUserDefaults is best for small amounts of non-sensitive data. NSCache is useful for caching objects in memory. Archives allow custom objects to be encoded and stored. Core Data provides a full object graph and relationship management system. iCloud syncs data across devices.
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.
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.
This document summarizes a lecture about data in iPhone applications. The lecture covers several topics: storing and loading local data using property lists, the iPhone's file system, archiving objects, SQLite databases, and accessing remote data via JSON and push notifications. It provides examples of writing arrays and dictionaries to property list files, explains the iPhone's application home directory structure, and gives an overview of archiving objects and using the SQLite database API.
we are innovative,we are different,we are genius so they call us idiots
Visit us for movies,videos,documentaries,sports,funny pics and many more join www.globalidiots.com
The document discusses various methods for persistent storage in iOS, including NSUserDefaults for simple preferences, archiving objects to files by conforming to the NSCoding protocol, writing directly to files using NSData, and using SQLite for relational databases. NSUserDefaults provides a simple mechanism to save and load primitive data types. Archiving allows saving object graphs to files by implementing encode and decode methods. Files can also be read and written using NSData methods. The document also covers the application sandbox structure.
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/
This document provides a summary of key aspects of NumPy, the fundamental package for scientific computing in Python. It introduces NumPy ndarrays as a more efficient way to store and manipulate numerical data compared to built-in Python data types. It then covers how to create ndarrays, their basic properties like shape and dtype, and common operations like slicing, sorting, random number generation, and aggregations.
1. Multi-level key-value observing allows objects to observe changes to properties across multiple levels of nested objects.
2. To implement multi-level KVO, the model must support dynamic property access using valueForUndefinedKey to traverse nested object hierarchies.
3. Observers must add and remove observation for each nested level, and handle change notifications separately for each level.
The document provides an overview of topics to be covered in an iPhone application development course, including:
1. The course schedule covers Objective-C basics, the MVC design pattern, networking services like Facebook API and location-based services.
2. Resources for self-study include the Stanford iOS course, Apple documentation, and books like "iOS Programming: The Big Nerd Ranch Guide."
3. Today's topics are the iPhone SDK, Objective-C language basics, common foundation classes, and creating a first iPhone application.
Core Data is a framework for managing object graphs and object lifecycles in iOS and macOS apps. It includes classes like NSManagedObjectModel, NSManagedObjectContext, and NSPersistentStoreCoordinator that make up the Core Data stack. Developers can create managed object subclasses to define entities, attributes, and relationships to represent application data. Objects can be created, fetched from the persistent store, modified, and saved back using Core Data APIs. Relationships allow objects to reference each other, and faults improve performance by lazily loading related objects only when needed.
This document provides an overview of Core Data, an object graph and persistence framework in iOS and macOS. It discusses key Core Data concepts like managed objects, fetch requests, relationships and the Core Data stack including NSManagedObjectContext, NSPersistentStoreCoordinator and NSManagedObjectModel. It also covers common tasks like inserting, updating and deleting managed objects as well as alternatives to Core Data like using SQLite directly via FMDB.
The document discusses various methods for persisting data in iOS applications, including UserDefaults, archiving with Codable and NSCoder, and using the file system. UserDefaults provides a simple way to store app settings but has limitations on data types. Archiving with Codable allows any object graph to be encoded into JSON or property lists for storage. The file system provides different directories like Documents and Caches within the app's sandbox for permanent and temporary storage.
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
Write a C++ program that implements a binary search tree (BST) to man.pdfhardjasonoco14599
Write a C++ program that implements a binary search tree (BST) to manage a number of integer
items with different priorities. In order to do so. you will need to maintain a queue as an item in
the tree. Each queue item is an integer. All items in a given queue will have the same priority. As
a new item with a user-specified priority comes in, it should be enqueued in the queue with items
of that priority. A new queue may need to created in case a queue with that priority does not
exist. Use dynamic memory to manage nodes in the queue and BST. Implement the following:
Constructor. Destructor. Overloaded copy constructor. Overloaded assignment operator.
Overloaded \"==\" operator to check if two trees are equal. A tree t1 is equal to t2 if for every
queue in t1, a corresponding queue with the same priority exists in t2 with the same set of
elements (the order of the elements in the queue docs not matter). Overloaded \"
Solution
program using namespace std;
#define width_unit 5
class BStree
{
private:
class Node
{
public:
int data;
Node *left, *right;
Node(int d=0)
:data(d), left(NULL), right(NULL) {}
};
Node *root;
Node * trav(int, Node * &);
void chop(Node * N);
void copy(Node * N);
void print(ostream &, Node *, int) const;
void print(Node *, int) const;
public:
BStree(void);
~BStree(void);
bool find(int);
void insert(int);
void remove(int);
bool empty(void) const;
Tree(const BStree &);
const BStree & operator=(const BStree &);
friend ostream & operator<<(ostream &, const BStree &);
};
BStree::BStree(void)
{
root=NULL;
}
bool Tree::empty(void) const
{
return !root;
}
BStree::Node * BStree::trav(int foo, Node * & par)
{
Node * curr=root;
par=NULL;
while(curr && curr->data != foo)
{
par=curr;
if(foo < curr->data)
curr=curr->left;
else
curr=curr->right;
}
return curr;
}
bool BStree::find(int foo)
{
Node * par=NULL;
Node * curr=trav(foo, par);
return curr;
}
void BStree::insert(int foo)
{
Node * par=NULL;
Node * curr=trav(foo,par);
if(!curr)
{
curr= new Node(foo);
if(!par)
root=curr;
else if(foo < par->data)
par->left=curr;
else
par->right=curr;
}
}
void BStree::remove(const int foo)
{
Node * par=NULL;
Node * curr=trav(foo,par);
if(curr)
{
if(curr->left && curr->right)
{
Node * tmp=curr;
par=curr;
curr=curr->left;
while(curr->right)
{
par=curr;
curr=curr->right;
}
tmp->data=curr->data;
}
Node *tmp=(curr->left ? curr->left : curr->right);
if(!par)
root=tmp;
else if(par->data < curr->data)
par->right=tmp;
else
par->left=tmp;
delete curr;
}
}
void BStree::chop(Node *N)
{
if(N)
{
chop(N->left);
chop(N->right);
delete N;
}
}
BStree::~BStree(void)
{
chop(root);
}
BStree::BStree(const BStree & T)
{
root=NULL;
copy(T.root);
}
void BStree::copy(Node * N)
{
if(N)
{
insert(N->data);
copy(N->left);
copy(N->right);
}
}
const BStree & BStree::operator=(const BStree & T)
{
if(this != &T)
{
chop(root);
root=NULL;
copy(T.root);
}
return *this;
}
void BStree::print(ostream & ost, Node * curr, int level) const
{
if(curr)
{
print(ost,curr->right,level+1);
ost<data<le.
The document discusses learning Ruby by reading its source code. It provides an overview of Ruby's basic object structure, with every object having an RBasic struct containing flags and a klass pointer. It describes the various structs used to represent different Ruby object types like integers, floats, strings, arrays, and classes. It details how Ruby uses singleton classes to implement class and instance methods. The document also explores Ruby's approach to class inheritance and module inclusion by examining how method lookup and class hierarchies are represented internally. It encourages spelunking the C source code to better understand how Ruby works under the hood.
The document provides an overview of JavaScript core concepts including:
- A brief history of JavaScript originating from LiveScript and becoming ECMAScript.
- Core misunderstandings about JavaScript being object-oriented and prototype-based.
- Key concepts like objects, functions, scope, 'this', arguments, invocation, and closures.
- How functions work with parameters, return values, and different invocation styles.
- Global versus function scope and how closures allow accessing outer function variables.
- Resources for further reading on JavaScript fundamentals.
2. Announcements
Get your Axess situation right.
If you have not turned in homework, e-mail us.
As they say in Air Traffic Control: state your intentions.
Homework
Any questions about the homework?
Wednesday, April 7, 2010
3. Communication
E-mail
Questions are best sent to cs193p@cs.stanford.edu
Sending directly to instructor or TA’s risks slow response.
Web Site
Very Important!
http://cs193p.stanford.edu
All lectures, assignments, code, etc. will be there.
This site will be your best friend when it comes to getting info.
Wednesday, April 7, 2010
4. Today’s Topics
Foundation Framework
NSArray, NSDictionary, NSSet
NSUserDefaults, etc.
Objective-C
Protocols and Delegates
Memory Management
Allocating and initializing objects
Reference Counting
Demo!
Wednesday, April 7, 2010
5. NSArray
NSArray
Ordered collection of objects
Cannot be modified once created
Important methods:
- (int)count
- (id)objectAtIndex:(int)index
- (void)makeObjectsPerformSelector:(SEL)aSelector
- (NSArray *)sortedArrayUsingSelector:(SEL)aSelector
NSMutableArray
Modifiable version of NSArray
- (void)addObject:(id)object
- (void)insertObject:(id)object atIndex:(int)index
- (void)removeObjectAtIndex:(int)index
- (void)replaceObjectAtIndex:(int)index withObject:(id)object
Wednesday, April 7, 2010
6. NSDictionary
NSDictionary
Cannot be modified once created!
Look up a value using a key (aka a “hash table”)
A key must implement - (NSUInteger)hash and - (BOOL)isEqual:(NSObject *)obj
Usually keys are NSString objects (since that implements those two)
Important methods:
- (int)count
- (id)objectForKey:(id)key
- (NSArray *)allKeys
- (NSArray *)allValues
NSMutableDictionary
Modifiable version of NSDictionary
- (void)setObject:(id)object forKey:(id)key
- (void)removeObjectForKey:(id)key
- (void)addEntriesFromDictionary:(NSDictionary *)dictionary
Wednesday, April 7, 2010
7. NSSet
NSSet
Unordered collection of objects without duplicates
Cannot be modified once created
Important methods:
- (int)count
- (BOOL)containsObject:(id)object
- (id)anyObject
- (void)makeObjectsPerformSelector:(SEL)aSelector
- (id)member:(id)object (uses isEqual: and returns a matching object)
NSMutableSet
Modifiable version of NSSet
- (void)addObject:(id)object
- (void)removeObject:(id)object
- (void)unionSet:(NSSet *)otherSet
- (void)minusSet:(NSSet *)otherSet
- (void)intersectSet:(NSSet *)otherSet
Wednesday, April 7, 2010
8. Enumeration
NSArray of NSString objects
NSArray *myArray = ...; / known to only have NSString objects inside
/
for (NSString *string in myArray) {
double value = [string doubleValue]; / crash if not NSString
/
}
NSArray of id
NSArray *myArray = ...; / no idea what kind of objects are inside
/
for (id obj in myArray) {
< do something with obj here, but make sure you don’t
send it a message it doesn’t respond to >
if ([obj isKindOfClass:[NSString class]]) {
/ send NSString messages to obj with impunity!
/
}
}
Wednesday, April 7, 2010
9. Enumeration
NSDictionary’s keys
NSDictionary *myDict = ...;
for (id key in [myDict allKeys]) {
< do something with the key >
}
NSDictionary’s values
NSDictionary *myDict = ...;
for (id value in [myDict allValues]) {
< do something with the value >
}
Wednesday, April 7, 2010
10. Property Lists
The term “Property List” just means “one of the
collection classes which contains only more collection
classes (nothing else).”
NSArray, NSDictionary, NSNumber, NSString, NSDate, NSData
So an NSArray is a Property List as long as all the
objects in it are also Property Lists.
An NSDictionary is a Property List as long as all the
keys and all the values are Property Lists.
Why make this distinction? The SDK has a number of
methods here and there which read/write Property Lists.
Wednesday, April 7, 2010
11. Other Foundation
NSUserDefaults
- (void)setDouble:(double)aDouble forKey:(NSString *)key
- (NSInteger)integerForKey:(NSString *)key
- (void)setObject:(id)obj forKey:(NSString *)key
(obj must be a Property List)
- (NSArray *)arrayForKey:(NSString *)key
(if the object stored for that key is not an NSArray, this returns nil)
- (void)synchronize / writes to permanent storage
/
NSNotification
NSTimer
NSThread
NSFileManager
Undo Manager
Wednesday, April 7, 2010
12. Protocols
Very similar to @interface, but no implementation
@protocol Foo
- (void)doSomething;
@optional
- (int)getSomething;
@required
- (NSArray *)getManySomethings:(int)howMany;
@end
Classes then proclaim they implement a protocol
@interface MyClass : NSObject <Foo>
...
@end
Wednesday, April 7, 2010
13. Protocols
Declaring arguments to require a protocol
- (void)giveMeTheObject:(id <Foo>)anObjectImplementingFoo
Declaring variables to require a protocol
id <Foo> obj = [[MyClass alloc] init];
[obj doSomething]; / will not warn (and should be okay)
/
Compiler will warn of misbehavior
Class says it implements protocol Foo, but doesn’t implement required methods
Assigning an object which does not implement Foo to a variable like obj above
Passing an object which does not implement Foo through an argument
which requires it (like above)
Wednesday, April 7, 2010
14. Delegate
Very common in SDK to have a property which is a “delegate”
Used to pass off responsibility to another object
The property will be declared (approximately) like this ...
@property id <MyClassDelegate> delegate;
Convenient for maintaining MVC boundaries but
still have documented interfaces between things
For example, the UITableView delegates both the provision of the data
and the content of what is drawn to other objects while implementing
the core of the user interaction itself
Wednesday, April 7, 2010
15. Creating Objects
Allocating and initializing
Send + (id)alloc to the class
Send appropriate initializer to what you get back
alloc allocates space for the instance variables
Default initializer (for NSObject and subclasses) is
- (id) init
NSObject’ init sets all instance variables to zero
s
Subclasses of NSObject might define new
initializers with more arguments
Initializers with fewer args should call those with more args (usually)
CalculatorBrain *brain = [[CalculatorBrain alloc] init];
UIView *view = [[UIView alloc] initWithFrame:aRect];
UIView *view = [[UIView alloc] init]; / some default frame
/
MyClass *obj = [MyClass alloc]; / ack! no init! don’t do this!
/
Wednesday, April 7, 2010
16. Creating Objects
Goofy implementation of initializers
#import <UIKit/UIKit.h> initWithFrame: is UIView’s “designated initializer”
so we, as a subclass, must call it in our DI.
We don’t have to override it, but we should
@implementation MyView if it makes any sense whatsoever to our class.
- (id)initWithFrame:(CGRect)aRect
{
if (self = [super initWithFrame:aRect]) {
/ initialize my class here
/
}
return self;
}
@end
Wednesday, April 7, 2010
17. Creating Objects
Asking other objects to create an object for you
NSString *s = [otherString stringByAppendingString:@”hi”];
NSArray *keys = [dictionary allKeys];
NSString *lowerString = [string lowercaseString];
NSNumber *n = [NSNumber numberWithFloat:9.0];
NSDate *date = [NSDate date]; / returns the date/time now
/
Wednesday, April 7, 2010
18. Memory Management
When does the memory get freed?
Garbage Collection!
NO, sorry.
Reference Counting
Wednesday, April 7, 2010
19. Reference Counting
Objects take ownership for other objects.
Multiple owners is okay.
Mechanism for taking “temporary” ownership.
When last object gives up ownership, deallocate.
Wednesday, April 7, 2010
20. Object Ownership
When you call alloc, you take ownership.
When you ask another object to create an object for you,
you are not taking ownership (with a couple of exceptions).
But if you want to access that object outside the
method you are in, you must take ownership.
You take ownership by sending the object you
want to own the message “retain.”
When you are done owning the object, send it “release.”
If you are the last owner, object will be freed.
Messages sent to that object after that will crash your application.
Wednesday, April 7, 2010
21. autorelease
What if you want to give an object to someone?
Usually you are doing this by returning it from one of your methods.
Before you return it to them, send the object
the message “autorelease” first.
UIKit will automatically send it release at some
later time (but not until call stack unwinds).
We’ll talk more about how this works when we get to threads.
All those NSString, NSArray, etc. methods are
returning “autoreleased” objects.
Wednesday, April 7, 2010
26. Other Ownership Rules
When you put an object in an NSArray or
NSDictionary, they do take ownership. When
you take an object out, they release ownership.
You also implicitly retain if you copy an object
This is done using the copy method.
Methods whose names start with
alloc, copy or new return an object you own
So you must release it at some point down the road
You should release an object as soon as possible
That is to say, the instant you are done with it.
Wednesday, April 7, 2010
27. Deallocation
What happens when the last owner releases?
A special method, - (void)dealloc, is called.
You should override this method and release
any instance variables you own.
And then be sure to call [super dealloc] to
let your superclass release it’s owned objects.
NEVER call dealloc. It is called automatically
when the last owner releases.
Wednesday, April 7, 2010
28. Properties
Remember @property?
Does the @synthesized getter method
return autoreleased object?
NO! That getter is returning an instance variable.
If the caller doesn’t retain it, then when your
object is deallocated, that caller will have a bad
pointer (assuming you properly releases your
instance variables in your dealloc).
Wednesday, April 7, 2010
29. Properties
Remember @property?
Does the @synthesized setter do a retain when
it is called?
You get to decide:
@property (retain) NSString *name;
@synthesize will create a setter equivalent to this ...
- (void)setName:(NSString *)aString
{
[name release];
name = [aString retain];
}
Wednesday, April 7, 2010
30. Properties
Remember @property?
Does the @synthesized setter do a retain when
it is called?
You get to decide:
@property (copy) NSString *name;
@synthesize will create a setter equivalent to this ...
- (void)setName:(NSString *)aString
{
[name release];
name = [aString copy];
}
Wednesday, April 7, 2010
31. Properties
Remember @property?
Does the @synthesized setter do a retain when
it is called?
You get to decide:
@property (assign) NSString *name;
@synthesize will create a setter equivalent to this ...
- (void)setName:(NSString *)aString
{
name = aString;
}
Wednesday, April 7, 2010
32. Wake up!
What about objects that come out of nib files?
They are archived in IB, then unarchived in your running app.
So where do you initialize if not in init?
- (void)awakeFromNib / override this NSObject method
/
- (void)viewDidLoad / only for UIViewController subclasses
/
Wednesday, April 7, 2010
33. viewDidUnload
And what about release-ing IBOutlets in UIViewControllers?
Don’t do it in dealloc because your controller’s views are
allowed to be “unloaded” to save memory when not on-screen.
Create @properties (retain) for all of them and then set them
to nil in the method viewDidUnload ...
@property (retain, nonatomic) IBOutlet UILabel *myOutlet;
- (void)viewDidUnload
{
self.myOutlet = nil; / this will release because property is retain
/
[super viewDidUnload]; / probably not necessary unless you think it is
/
}
When/if the view is reloaded, your outlets will get hooked
back up and - (void)viewDidLoad will get called (again).
Wednesday, April 7, 2010
35. Homework
Make your CalculatorBrain support variables
Mostly NSArray, NSDictionary work
Some Instrospection
Get Memory Management right!
Not too difficult, but a new concept. Be diligent!
Wednesday, April 7, 2010
36. Next Week
Custom Views, Navigation Controllers
Wednesday, April 7, 2010