How to resolve the algorithm Host introspection step by step in the Objective-C programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Host introspection step by step in the Objective-C programming language

Table of Contents

Problem Statement

Print the word size and endianness of the host machine. See also: Variable size/Get

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Host introspection step by step in the Objective-C programming language

Source code in the objective-c programming language

switch (NSHostByteOrder()) {
  case NS_BigEndian:
    NSLog(@"%@", @"Big Endian");
    break;
  case NS_LittleEndian:
    NSLog(@"%@", @"Little Endian");
    break;
  case NS_UnknownByteOrder:
    NSLog(@"%@", @"endianness unknown");
    break;
}


switch ([NSRunningApplication currentApplication].executableArchitecture) {
  case NSBundleExecutableArchitectureI386:
    NSLog(@"%@", @"i386 32-bit");
    break;

  case NSBundleExecutableArchitectureX86_64:
    NSLog(@"%@", @"x86_64 64-bit");
    break;

  case NSBundleExecutableArchitecturePPC:
    NSLog(@"%@", @"PPC 32-bit");
    break;

  case NSBundleExecutableArchitecturePPC64:
    NSLog(@"%@", @"PPC64 64-bit");
    break;

  default:
    NSLog(@"%@", @"Unknown");
    break;
}


  

You may also check:How to resolve the algorithm URL encoding step by step in the OCaml programming language
You may also check:How to resolve the algorithm Polynomial regression step by step in the J programming language
You may also check:How to resolve the algorithm Longest common substring step by step in the Julia programming language
You may also check:How to resolve the algorithm Man or boy test step by step in the Fantom programming language
You may also check:How to resolve the algorithm Negative base numbers step by step in the ALGOL 68 programming language