Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  introspection.rs   Sprache: Rust

 

use objc2::runtime::{AnyClass, NSObject};
use objc2::{sel, ClassType, Encode};

fn main() {
    // Get the class representing `NSObject`
    let cls = NSObject::class();

    // Inspect various properties of the class
    println!("NSObject superclass: {:?}", cls.superclass());
    println!("NSObject size: {}", cls.instance_size());
    println!(
        "-[NSObject alloc] would work: {}",
        cls.responds_to(sel!(alloc))
    );
    println!(
        "+[NSObject alloc] would work: {}",
        cls.metaclass().responds_to(sel!(alloc))
    );

    // Inspect an instance variable on the class
    //
    // Note: You should not rely on the `isa` ivar being available,
    // this is only for demonstration.
    let ivar = cls
        .instance_variable(c"isa")
        .expect("no ivar with name 'isa' found on NSObject");
    println!(
        "Instance variable {:?} has type encoding {:?}",
        ivar.name(),
        ivar.type_encoding()
    );
    assert!(<*const AnyClass>::ENCODING.equivalent_to_str(ivar.type_encoding().to_str().unwrap()));

    // Inspect a method of the class
    let method = cls.instance_method(sel!(hash)).unwrap();
    println!(
        "-[NSObject hash] takes {} parameters",
        method.arguments_count()
    );
    let hash_return = method.return_type();
    println!("-[NSObject hash] return type: {hash_return:?}");
    assert!(usize::ENCODING.equivalent_to_str(hash_return.to_str().unwrap()));

    // Create an instance
    let obj = NSObject::new();

    println!("NSObject address: {obj:p}");

    // Read an ivar on the object
    let isa: *const AnyClass = unsafe { *ivar.load(&obj) };
    println!("NSObject isa: {isa:?}");
}

Messung V0.5 in Prozent
C=83 H=84 G=83

¤ Dauer der Verarbeitung: 0.18 Sekunden  (vorverarbeitet am  2026-10-03) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1126864
#Domains=1897691