There are quite a few ways of doing it, but this is what I do.
Add a saved Variables field to the toc:
Code:
## SavedVariables: MyAddonSV
Create an event handler for ADDON_LOADED and assign a table to MyAddonSV if it doesn't have one, and optionally set up defaults.
ie.
Code:
local eframe = CreateFrame("Frame")
eframe:RegisterEvent("ADDON_LOADED")
eframe:SetScript("OnEvent", function(self, event, addon)
self:UnregisterEvent("ADDON_LOADED")
self:SetScript("OnEvent", nil)
MyAddonSV = MyAddonSV or {}
end)
MyAddonSV now operates like any other table except it's stored on reload.