Ver Mensaje Individual
  #8  
Antiguo 02-09-2024
Avatar de mamcx
mamcx mamcx is offline
Moderador
 
Registrado: sep 2004
Ubicación: Medellín - Colombia
Posts: 3.939
Reputación: 27
mamcx Tiene un aura espectacularmamcx Tiene un aura espectacularmamcx Tiene un aura espectacular
Hay maneras para evitar un stack overflow:

Usando la ultima forma, porque parece que estas intentando es hacer un 'Navigation Controller` como: https://developer.apple.com/document...tioncontroller, y es muy fácil de esquematizar:


Código Delphi [-]
type
  TView = (Root, ScreenA, ScreenB);


type
  TNavigationStack = class
  private
    FStack: TArray;
  public
    constructor Create;
    procedure Push(View: TView);
    function Pop: TView;
    function Current: TView;
  end;


constructor TNavigationStack.Create;
begin
  SetLength(FStack, 1);
  FStack[0] := Root;  // Start with the root view
end;

procedure TNavigationStack.Push(View: TView);
begin
  SetLength(FStack, Length(FStack) + 1);
  FStack[High(FStack)] := View;
end;

function TNavigationStack.Pop: TView;
begin
  if Length(FStack) > 1 then
  begin
    Result := FStack[High(FStack)];
    SetLength(FStack, Length(FStack) - 1);
  end
  else
    Result := Root;  // Prevent popping the root view
end;

function TNavigationStack.Current: TView;
begin
  Result := FStack[High(FStack)];
end;
__________________
El malabarista.
Responder Con Cita