0Pricing
Objective-C iOS Development for Legacy & Enterprise Apps · Aula

Sintaxe e Tipos de Dados Básicos

Aprenda a sintaxe fundamental, os tipos de dados primitivos e objetos comuns do Objective-C, como NSString e NSArray.

Sintaxe e Tipos de Dados Básicos é uma aula grátis de Objective-C iOS Development for Legacy & Enterprise Apps no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Objective-C iOS Development for Legacy & Enterprise Apps, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Objective-C iOS Development for Legacy & Enterprise Apps inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Objective-C Basics

Time for the fundamentals: Objective-C's basic syntax and the data types you will work with every day.

Statements End with Semicolons

Like other C-based languages, every Objective-C statement ends with a semicolon. Forget one and Xcode will flag it fast.

Explain Your Code with Comments

Comments are notes the compiler ignores. Use // for a single line and /* */ for multi-line blocks.

Primitive Data Types

Primitive types hold simple values: int, float/double, char, and BOOL (which is YES or NO).

Primitives in Action

Here those primitive types come to life — declared, assigned, and printed with NSLog format specifiers.

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
  @autoreleasepool {
    int age = 30;
    float price = 19.99f; // 'f' for float literal
    double pi = 3.14159;
    char initial = 'J';
    BOOL isLoggedIn = YES;

    NSLog(@"Age: %i", age);
    NSLog(@"Price: %.2f", price);
    NSLog(@"Pi: %f", pi);
    NSLog(@"Initial: %c", initial);
    NSLog(@"Logged In: %@", isLoggedIn ? @"YES" : @"NO");
  }
  return 0;
}

Working with Text: NSString

For words and sentences you use the NSString object, not char. NSString is immutable: its contents never change after creation.

NSString Example

Declaring an NSString uses the @ prefix before the literal — a piece of syntax unique to Objective-C.

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
  @autoreleasepool {
    NSString *greeting = @"Hello, CoddyKit!";
    NSString *name = @"Alice";
    NSString *message = [NSString stringWithFormat:@"Welcome, %@!", name];

    NSLog(@"Greeting: %@", greeting);
    NSLog(@"Personal Message: %@", message);
  }
  return 0;
}

Collections: NSArray

NSArray stores an ordered list of objects, accessed by zero-based index. It is immutable; use NSMutableArray when you need to change it.

NSArray Example

Create an NSArray with the @[] literal. The older arrayWithObjects form needs a nil terminator.

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
  @autoreleasepool {
    // Array literal syntax
    NSArray *fruits = @[@"Apple", @"Banana", @"Cherry"];

    NSLog(@"First fruit: %@", fruits[0]); // Access by index
    NSLog(@"All fruits: %@", fruits);

    // Another way to create (older, but good to know)
    NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", nil];
    NSLog(@"Colors: %@", colors);
  }
  return 0;
}

Quick Check on Types

Consider the following Objective-C declarations. Which one correctly defines a boolean variable named isActive and sets it to true?

Recap: Syntax & Data Types

Recap: semicolons end statements, comments document, primitives like int and BOOL hold simple values, and NSString and NSArray handle text and lists.

Perguntas Frequentes

A aula “Sintaxe e Tipos de Dados Básicos” é grátis?

Sim — o texto completo de “Sintaxe e Tipos de Dados Básicos” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Objective-C iOS Development for Legacy & Enterprise Apps, atualize para CoddyKit PRO. O curso de Objective-C iOS Development for Legacy & Enterprise Apps inclui 4 aulas no total.

O que vou aprender em “Sintaxe e Tipos de Dados Básicos”?

Aprenda a sintaxe fundamental, os tipos de dados primitivos e objetos comuns do Objective-C, como NSString e NSArray. Você pratica Objective-C iOS Development for Legacy & Enterprise Apps com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Objective-C iOS Development for Legacy & Enterprise Apps?

Nenhuma experiência prévia é necessária. Objective-C iOS Development for Legacy & Enterprise Apps no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Sintaxe e Tipos de Dados Básicos”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Objective-C iOS Development for Legacy & Enterprise Apps?

Sim. Cada aula de Objective-C iOS Development for Legacy & Enterprise Apps inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Introdução ao Objective-C
  2. Sintaxe e Tipos de Dados Básicos
  3. Configuração do Xcode para Objective-C
  4. Trabalhar com NSString e Tipos Foundation
← Voltar para Objective-C iOS Development for Legacy & Enterprise Apps