An image pickup apparatus which is capable of removing foreign substance,
such as dust, attached to an optical member disposed in front of an image
pickup element, even when accessories are exchanged in a power-off state
of the image pickup apparatus. The type or state of an accessory mounted
on the image pickup apparatus, which is detected immediately before a
power-off of the image pickup apparatus are stored. When a type or state
of a mounted accessory, which is detected immediately after the power-on,
is different from the stored type or state of the accessory mounted on
the image pickup apparatus, an operation for removing foreign substance
attached to the optical member is carried out.