What happens when you try to launch a null object in the c target?

advertisements

I've got the following code:

[application.tripHandler createTrip:picker.date
                          pickUpAddress:[ModelUtil addresFragmentFromGeoAddress:pickUpAddress]
                       orPickUpLocation:pickUpFavorite
                      andDropOffAddress:[ModelUtil addresFragmentFromGeoAddress:dropOffAddress]
                      orDropOffLocation:dropOffFavorite forDriver:application.currentDriver.driverId
                             completion:^(NSObject *entity)
     {
         if(application.dispatchVehicle)
         {
             Trip *createdTrip = (Trip *)entity;

What happens when entity is null?


If entity is nil, then createdTrip will be nil as well.

(nil and NULL are technically the same thing, but nil is semantically the null object value whereas NULL is the null pointer).

Casting a pointer does not actually do anything at runtime. It merely modifies the type being pointed-to, which then affects subsequent operations on the resulting value. But the actual pointer value will remain the same through the cast.