just my two cents advise to get a inverter, best if UPS protected, if the voltage fluctuate it can cause damage to your imac.
directly connect to your imac is not a good idea imo.
While the generator is starting, the generator voltage and frequency are not stable.
it would be good to place a UPS between.
e.g.
12V outlet >>> inverter >> ups >> imac
maybe someone has a better idea or product to help?