Learning to perform perfect tracking tasks based on measurement data is desirable in the controller design of systems operating repetitively. This motivates this article to seek an optimization-based design and analysis approach for data-driven learning control systems by focusing on iterative learning control (ILC) of repetitive systems with unknown nonlinear time-varying dynamics. It is shown that perfect output tracking can be realized with updating inputs, where no explicit model knowledge but only measured input-output data are leveraged. In particular, adaptive updating strategies are proposed to obtain parameter estimations of nonlinearities. A double-dynamics analysis approach is applied to establish ILC convergence, together with boundedness of input, output, and estimated parameters, which benefits from employing properties of nonnegative matrices. Simulations are implemented to verify the validity of our optimization-based adaptive ILC.