Capítulo 1 El Lenguaje De Programación Objectivec

Total Page:16

File Type:pdf, Size:1020Kb

Capítulo 1 El Lenguaje De Programación Objectivec www.gnustep.wordpress.com Introducción al entorno de desarrollo GNUstep 1 www.gnustep.wordpress.com Introducción al entorno de desarrollo GNUstep Licencia de este documento Copyright (C) 2008, 2009 German A. Arias. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". 2 www.gnustep.wordpress.com Introducción al entorno de desarrollo GNUstep Tabla de Contenidos INTRODUCCIÓN.....................................................................................................................................6 Capítulo 0...................................................................................................................................................7 Instalación de GNUstep y las especificaciones OpenStep.........................................................................7 0.1 Instalando GNUstep........................................................................................................................8 0.2 Especificaciones OpenStep...........................................................................................................12 0.3 Estableciendo las teclas modificadoras.........................................................................................13 Capítulo 1.................................................................................................................................................16 El lenguaje de programación Objective-C...............................................................................................16 1.1 Palabras reservadas de Objective-C..............................................................................................17 1.2 Librerías.........................................................................................................................................18 1.3 La función main.............................................................................................................................19 1.4 Nuestro primer programa..............................................................................................................19 1.5 Declaración de variables...............................................................................................................20 1.6 Las funciones printf() y scanf().....................................................................................................23 1.7 Nuestro segundo programa............................................................................................................25 Capítulo 2.................................................................................................................................................27 Operadores, sentencias y funciones.........................................................................................................27 2.1 Operadores aritméticos..................................................................................................................27 2.2 Operadores relacionales................................................................................................................28 2.3 Operadores lógicos........................................................................................................................29 2.4 Sentencias condicionales...............................................................................................................30 2.5 Sentencias iterativas......................................................................................................................33 2.6 Nuestro tercer programa................................................................................................................35 2.7 Nuestro cuarto programa...............................................................................................................36 2.8 Funciones ......................................................................................................................................38 2.9 Matrices.........................................................................................................................................42 2.10 Quinto programa..........................................................................................................................43 2.11 Sexto programa............................................................................................................................44 2.12 Más operadores............................................................................................................................46 2.13 Comentarios.................................................................................................................................47 Capítulo 3.................................................................................................................................................48 Programación orientada a objetos (POO)................................................................................................48 3.1 Clases y Objetos............................................................................................................................48 3.2 Librerías Base y GUI, y herencia..................................................................................................52 3.3 Clases y Objetos en GNUstep.......................................................................................................53 3.4 Mensajes........................................................................................................................................56 3.5 Outlets y Actions...........................................................................................................................57 3 www.gnustep.wordpress.com Introducción al entorno de desarrollo GNUstep Capítulo 4.................................................................................................................................................60 Nuestro primer programa con GNUstep..................................................................................................60 4.1 Creando la interfaz gráfica............................................................................................................60 4.2 Escribiendo código para nuestro Objeto.......................................................................................73 4.3 Compilando y ejecutando nuestra aplicación ..............................................................................79 4.4 Mejorando nuestra aplicación.......................................................................................................82 Capítulo 5.................................................................................................................................................87 Nuevos conceptos y algunas aplicaciones de ejemplo.............................................................................87 5.1 Strings............................................................................................................................................87 5.2 Métodos de Instancia y Métodos de Clase....................................................................................88 5.3 Nuevamente Outlets y Actions......................................................................................................89 5.4 NSPoint, NSSize y NSRect...........................................................................................................91 5.5 El método awakeFromNib.............................................................................................................93 Capítulo 6.................................................................................................................................................94 Profundizando en Objective-C.................................................................................................................94 6.1 Métodos.........................................................................................................................................94 6.2 Ciclo de vida de los objetos y gestión de la memoria...................................................................95 6.2.1 Constructores convenientes (métodos factory)......................................................................96 6.2.2 alloc e init..............................................................................................................................97 6.2.3 autorelease.............................................................................................................................98 6.3 Mas sobre el ciclo de vida de los objetos......................................................................................99 6.4 Inicializadores de máxima genericidad.......................................................................................101 6.5 Re-definición de métodos init y dealloc y los receptores self y super ......................................103 Capítulo 7...............................................................................................................................................106 Integrando todo......................................................................................................................................106
Recommended publications
  • Xcode Package from App Store
    KH Computational Physics- 2016 Introduction Setting up your computing environment Installation • MAC or Linux are the preferred operating system in this course on scientific computing. • Windows can be used, but the most important programs must be installed – python : There is a nice package ”Enthought Python Distribution” http://www.enthought.com/products/edudownload.php – C++ and Fortran compiler – BLAS&LAPACK for linear algebra – plotting program such as gnuplot Kristjan Haule, 2016 –1– KH Computational Physics- 2016 Introduction Software for this course: Essentials: • Python, and its packages in particular numpy, scipy, matplotlib • C++ compiler such as gcc • Text editor for coding (for example Emacs, Aquamacs, Enthought’s IDLE) • make to execute makefiles Highly Recommended: • Fortran compiler, such as gfortran or intel fortran • BLAS& LAPACK library for linear algebra (most likely provided by vendor) • open mp enabled fortran and C++ compiler Useful: • gnuplot for fast plotting. • gsl (Gnu scientific library) for implementation of various scientific algorithms. Kristjan Haule, 2016 –2– KH Computational Physics- 2016 Introduction Installation on MAC • Install Xcode package from App Store. • Install ‘‘Command Line Tools’’ from Apple’s software site. For Mavericks and lafter, open Xcode program, and choose from the menu Xcode -> Open Developer Tool -> More Developer Tools... You will be linked to the Apple page that allows you to access downloads for Xcode. You wil have to register as a developer (free). Search for the Xcode Command Line Tools in the search box in the upper left. Download and install the correct version of the Command Line Tools, for example for OS ”El Capitan” and Xcode 7.2, Kristjan Haule, 2016 –3– KH Computational Physics- 2016 Introduction you need Command Line Tools OS X 10.11 for Xcode 7.2 Apple’s Xcode contains many libraries and compilers for Mac systems.
    [Show full text]
  • GNU Scientific Library – Reference Manual
    GNU Scientific Library – Reference Manual: Top http://www.gnu.org/software/gsl/manual/html_node/ GNU Scientific Library – Reference Manual Next: Introduction, Previous: (dir), Up: (dir) [Index] GSL This file documents the GNU Scientific Library (GSL), a collection of numerical routines for scientific computing. It corresponds to release 1.16+ of the library. Please report any errors in this manual to [email protected]. More information about GSL can be found at the project homepage, http://www.gnu.org/software/gsl/. Printed copies of this manual can be purchased from Network Theory Ltd at http://www.network-theory.co.uk /gsl/manual/. The money raised from sales of the manual helps support the development of GSL. A Japanese translation of this manual is available from the GSL project homepage thanks to Daisuke Tominaga. Copyright © 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The GSL Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections and no cover texts. A copy of the license is included in the section entitled “GNU Free Documentation License”. • Introduction: • Using the library: • Error Handling: • Mathematical Functions: • Complex Numbers: • Polynomials: • Special Functions: • Vectors and Matrices: • Permutations: • Combinations: • Multisets: • Sorting: • BLAS Support: • Linear Algebra: • Eigensystems:
    [Show full text]
  • Quantian: a Scientific Computing Environment
    New URL: http://www.R-project.org/conferences/DSC-2003/ Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003) March 20–22, Vienna, Austria ISSN 1609-395X Kurt Hornik, Friedrich Leisch & Achim Zeileis (eds.) http://www.ci.tuwien.ac.at/Conferences/DSC-2003/ Quantian: A Scientific Computing Environment Dirk Eddelbuettel [email protected] Abstract This paper introduces Quantian, a scientific computing environment. Quan- tian is directly bootable from cdrom, self-configuring without user interven- tion, and comprises hundreds of applications, including a significant number of programs that are of immediate interest to quantitative researchers. Quantian is available at http://dirk.eddelbuettel.com/quantian.html. 1 Introduction Quantian is a directly bootable and self-configuring Linux system on a single cdrom. Quantian is an extension of Knoppix (Knopper, 2003) from which it takes its base system of about 2.0 gigabytes of software, along with automatic hardware detec- tion and configuration. Quantian adds software with a quantitative, numerical or scientific focus such as R, Octave, Ginac, GSL, Maxima, OpenDX, Pari, PSPP, QuantLib, XLisp-Stat and Yorick. This paper is organized as follows. In the next section, we introduce the Debian distribution upon which Knopppix and, thus, Quantian are built, discuss Debian packages and its packaging system and provide an overview of the support for R and its related programs. We also describe the Knoppix system and provide a basic outline of Quantian. In the ensuing section, we describe the Quantian build process. Possible extensions are discussed in the following section before a short summary concludes the paper. 2 Background Quantian builds on Knoppix, which is itself based on Debian.
    [Show full text]
  • Programming for Science Fairs a Student’S Guide to Resources, Usage and Display
    Programming for Science Fairs A student’s guide to resources, usage and display Rajalakshmi Kollengode Contents 1.0 Resources 1.1 Learning Resources to Learn the Fundamental Concepts 1.2 Other Resources: Libraries and APIs 1.3 Resources for Math Projects 1.4 Resources for Physics Projects 1.5 Resources for Biology Projects 1.6 Resources for Chemistry Projects 1.7 Resources for Projects in Social Studies 2.0 Usage Considerations Some ideas on how to include programming in science fair projects 2.1 Usage for computational projects 2.2 Usage for non-computational projects 3.0 Coding Display Considerations Some recommendations for the big day 3.1 Display guidelines for computational projects 3.2 Display guidelines for non-computational projects Preface There is a wide variety of both free and paid resources available on the web. Many of them focus on gaming as a tool to learn elements of programming. Many other sites focus on coding for content creation (as in blogs), graphics design, collaborating and marketing. Not many of these are directly relevant to Science Fairs. While doing a science fair project, the student’s programming needs depend on the category and field of study the project belongs to. We can broadly divide the projects into two groups: (a) computational sciences (software engineering, robotics, informatics etc.) and (b) non-computational sciences (behavioral science, biochemistry, biology, chemistry, physics, engineering and mathematics excluding algorithms for numerical methods). For computational sciences, the main line is programming irrespective of field of study. In this case, the project would need a great amount of coding.
    [Show full text]
  • Best Practice Guide - Generic X86 Vegard Eide, NTNU Nikos Anastopoulos, GRNET Henrik Nagel, NTNU 02-05-2013
    Best Practice Guide - Generic x86 Vegard Eide, NTNU Nikos Anastopoulos, GRNET Henrik Nagel, NTNU 02-05-2013 1 Best Practice Guide - Generic x86 Table of Contents 1. Introduction .............................................................................................................................. 3 2. x86 - Basic Properties ................................................................................................................ 3 2.1. Basic Properties .............................................................................................................. 3 2.2. Simultaneous Multithreading ............................................................................................. 4 3. Programming Environment ......................................................................................................... 5 3.1. Modules ........................................................................................................................ 5 3.2. Compiling ..................................................................................................................... 6 3.2.1. Compilers ........................................................................................................... 6 3.2.2. General Compiler Flags ......................................................................................... 6 3.2.2.1. GCC ........................................................................................................ 6 3.2.2.2. Intel ........................................................................................................
    [Show full text]
  • GNU Astronomy Utilities
    GNU Astronomy Utilities Astronomical data manipulation and analysis programs and libraries for version 0.7, 8 August 2018 Mohammad Akhlaghi Gnuastro (source code, book and webpage) authors (sorted by number of commits): Mohammad Akhlaghi ([email protected], 1101) Mos`eGiordano ([email protected], 29) Vladimir Markelov ([email protected], 18) Boud Roukema ([email protected], 7) Leindert Boogaard ([email protected], 1) Lucas MacQuarrie ([email protected], 1) Th´er`eseGodefroy ([email protected], 1) This book documents version 0.7 of the GNU Astronomy Utilities (Gnuastro). Gnuastro provides various programs and libraries for astronomical data manipulation and analysis. Copyright c 2015-2018 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled \GNU Free Documentation License". For myself, I am interested in science and in philosophy only because I want to learn something about the riddle of the world in which we live, and the riddle of man's knowledge of that world. And I believe that only a revival of interest in these riddles can save the sciences and philosophy from narrow specialization and from an obscurantist faith in the expert's special skill, and in his personal knowledge and authority; a faith that so well fits our `post-rationalist' and `post- critical' age, proudly dedicated to the destruction of the tradition of rational philosophy, and of rational thought itself.
    [Show full text]
  • Introduction to Matlab
    Numerical Libraries with C or Fortran Shaohao Chen Research Computing, IS&T, Boston University Outline 1. Overview: What? Why? How to? 2. Fast Fourier transform: FFTw 3. Linear algebra libraries: LAPACK/BLAS 4. Intel Math Kernel Library (MKL) 5. Krylov subspace solver: PETSc 6. GNU scientific libraries (GSL) 1. Overview What you will learn today • Basic knowledge of numerical libraries. • How to check available libraries on BU SCC. • How to use numerical libraries on BU SCC. • Basic programming with several numerical libraries: FFTw, LAPACK/BLAS, MKL, PETSc, GSL What is numerical library? • What is the definition of a library in computer science? In computer science, a library is a collection of non-volatile resources used by computer programs, often to develop software. These may include configuration data, documentation, help data, message templates, pre-written code and subroutines, classes, values or type specifications. (from wiki) • What is numerical library? Numerical library is collection of functions, subroutines or classes that implement mathematical or numerical methods for a certain subject. Usually these functions or routines are common and can be used to build computer programs for various research fields. Several widely-used numerical libraries • Fastest Fourier Transform in the West (FFTW) computes Fourier and related transforms. Written in C. Fortran interface is available. • Basic Linear Algebra Subprograms (BLAS) performs basic vector and matrix operations. Linear Algebra Package (LAPACK) provides linear algebra routines based on BLAS. Written in Fortran. C interface (CBLAS/LAPACKE) is available. • Intel Math Kernel Library (MKL) includes optimized LAPACK, BLAS, FFT, Vector Math and Statistics functions. C/C++ and Fortran interfaces are available.
    [Show full text]
  • Gnu Scientific Library Reference Manual
    Gnu Scientific Library Reference Manual Unrestful and gynaecological Bertrand nickelised some Barra so plaguy! Numberless Godfry always champs his rota if Manny is syntactic or rooms deathy. Suggestive Hadley sometimes disprizing his jura despairingly and demilitarize so participially! Internet sites nclab and reference library manual library routines and themes for describing the online photo editor is a work has a single MATLAB constantly works with matrices. On many other loop constructs have found by this gnu free ibm spss statistics is so that beginners can check out calculations ranging from gnu scientific library reference manual, moore iii random bitstream it? If you have an arm. Dtmf matlab source code. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement. Golang coap golang coap golang coap golang coap golang coap golang coap golang coap golang coap golang coap golang coap. The following plot shows the distribution of the selected events. You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. Exercises are intended to require nontrivial derivations or proofs of facts either asserted without proof in the chapter or extensions thereof. For example, when numerically integrating a function defined by a parameterized series where the parameter varies only slightly.
    [Show full text]
  • Basic Seismic Utilities User's Guide
    Basic Seismic Utilities User's Guide Dr. P. Michaels, PE 30 April 2002 <[email protected]> Release 1.0 Version 1 Software for Engineering Geophysics Center for Geophysical Investigation of the Shallow Subsurface Boise State University Boise, Idaho 83725 2 Acknowledgements I have built on the work of many others in the development of this package. I would like to thank Enders A. Robinson and the Holden-Day Inc., Liquidation Trust (1259 S.W. 14th Street, Boca Raton, FL 33486, Phone: 561.750-9229 Fax: 561.394.6809) for license to include and distribute under the GNU license subroutines found in Dr. Robinson’s 1967 book [14] , Multichannel time series analysis with digital computer programs. This book is currently out of print, but contains a wealth of algorithms, several of which I have found useful and included in the BSU Fortran77 subroutine library (sublib4.a). This has saved me considerable time. In other cases, subroutines taken from the book Numerical Recipes [12] had to be replaced (the publisher did not give permission to distribute). While this is an excellent book, and very instructional for those interested in the theory of the algorithms, future authors of software should know that the algorithms given in that book are NOT GNU. Replacement software was found in the GNU Scientific Library (GSL), and in the CMLIB. The original plotting software was from PGPLOT (open source, but distribution restricted). These codes have since been replaced with GNU compliant PLPLOT routines. PLPLOT credits include Dr. Maurice LeBrun <[email protected]> and Geoffrey Furnish <[email protected]>.
    [Show full text]
  • Red Hat Linux 6.0
    Red Hat Linux 6.0 The Official Red Hat Linux Installation Guide Red Hat Software, Inc. Durham, North Carolina Copyright ­c 1995, 1996, 1997, 1998, 1999 Red Hat Software, Inc. Red Hat is a registered trademark and the Red Hat Shadow Man logo, RPM, the RPM logo, and Glint are trademarks of Red Hat Software, Inc. Linux is a registered trademark of Linus Torvalds. Motif and UNIX are registered trademarks of The Open Group. Alpha is a trademark of Digital Equipment Corporation. SPARC is a registered trademark of SPARC International, Inc. Products bearing the SPARC trade- marks are based on an architecture developed by Sun Microsystems, Inc. Netscape is a registered trademark of Netscape Communications Corporation in the United States and other countries. TrueType is a registered trademark of Apple Computer, Inc. Windows is a registered trademark of Microsoft Corporation. All other trademarks and copyrights referred to are the property of their respective owners. ISBN: 1-888172-28-2 Revision: Inst-6.0-Print-RHS (04/99) Red Hat Software, Inc. 2600 Meridian Parkway Durham, NC 27713 P. O. Box 13588 Research Triangle Park, NC 27709 (919) 547-0012 http://www.redhat.com While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein. The Official Red Hat Linux Installation Guide may be reproduced and distributed in whole or in part, in any medium, physical or electronic, so long as this copyright notice remains intact and unchanged on all copies.
    [Show full text]
  • Synthesis of Super-Heavy Elements: Role of Uncertainty Analysis in Theoretical Modeling Hongliang Lu
    Synthesis of Super-Heavy Elements: Role of Uncertainty Analysis in Theoretical Modeling Hongliang Lu To cite this version: Hongliang Lu. Synthesis of Super-Heavy Elements: Role of Uncertainty Analysis in Theoretical Modeling. Nuclear Theory [nucl-th]. Universit´ede Caen Normandie, 2015. English. <tel- 01235448> HAL Id: tel-01235448 http://hal.in2p3.fr/tel-01235448 Submitted on 30 Nov 2015 HAL is a multi-disciplinary open access L'archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destin´eeau d´ep^otet `ala diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publi´esou non, lished or not. The documents may come from ´emanant des ´etablissements d'enseignement et de teaching and research institutions in France or recherche fran¸caisou ´etrangers,des laboratoires abroad, or from public or private research centers. publics ou priv´es. Université de Caen Normandie U.F.R. de Sciences École Doctorale SIMEM Thèse de doctorat présentée et soutenue le : 18/11/2015 par Monsieur Hongliang LÜ pour obtenir le Doctorat de l’Université de Caen Normandie Spécialité : Constituants élémentaires et physique théorique Synthèse des noyaux super-lourds : Rôle de l'analyse d'incertitude dans la modélisation MEMBRES du JURY : M. D. ACKERMANN Akademische Direktor, GSI, Darmstadt, Allemagne (Rapporteur) M. G. ROYER Professeur, Université de Nantes, Nantes (Rapporteur) Mme F. GULMINELLI Professeur, Normandie Université, Caen (Présidente du jury) Mme B. JURADO Chargée de recherche, GENBG, Gradignan (Examinatrice) M. A. CHBIHI Directeur de recherche, GANIL, Caen (Directeur de thèse) M. D. BOILLEY Maître de conférence, Normandie Université, Caen (Encadrant) GANIL T 2015 03 If a man will begin with certainties, he shall end in doubts; but if he will be content to begin with doubts he shall end in certainties.
    [Show full text]
  • Rcppgsl: Easier GSL Use from R Via Rcpp
    RcppGSL: Easier GSL use from R via Rcpp Dirk Eddelbuettel Romain François Version 0.2.0.3 as of October 23, 2013 Abstract The GNU Scientific Library, or GSL, is a collection of numerical routines for scientific computing (Galassi et~al., 2010). It is particularly useful for C and C++ programs as it provides a standard C interface to a wide range of mathematical routines such as special functions, permutations, combinations, fast fourier transforms, eigensys- tems, random numbers, quadrature, random distributions, quasi-random sequences, Monte Carlo integration, N-tuples, differential equations, simulated annealing, numerical differentiation, interpolation, series accelera- tion, Chebyshev approximations, root-finding, discrete Hankel transforms physical constants, basis splines and wavelets. There are over 1000 functions in total with an extensive test suite. The RcppGSL package provides an easy-to-use interface between GSL data structures and R using concepts from Rcpp (Eddelbuettel and François, 2011, 2013; Eddelbuettel, 2013) which is itself a package that eases the interfaces between R and C++. 1 Introduction The GNU Scientific Library, or GSL, is a collection of numerical routines for scientific computing (Galassi et~al., 2010). It is a rigourously developed and tested library providing support for a wide range of scientific or numerical tasks. Among the topics covered in the GSL are complex numbers, roots of polynomials, special functions, vector and matrix data structures, permutations, combinations, sorting, BLAS support, linear alge- bra, fast fourier transforms, eigensystems, random numbers, quadrature, random distributions, quasi-random sequences, Monte Carlo integration, N-tuples, differential equations, simulated annealing, numerical differen- tiation, interpolation, series acceleration, Chebyshev approximations, root-finding, discrete Hankel transforms least-squares fitting, minimization, physical constants, basis splines and wavelets.
    [Show full text]