{"id":130,"date":"2008-06-25T15:44:59","date_gmt":"2008-06-25T21:44:59","guid":{"rendered":"http:\/\/www.philhassey.com\/blog\/?p=130"},"modified":"2008-06-25T15:47:47","modified_gmt":"2008-06-25T21:47:47","slug":"igalcon-main-menu-confusion-over-save-restore-state","status":"publish","type":"post","link":"https:\/\/www.philhassey.com\/blog\/2008\/06\/25\/igalcon-main-menu-confusion-over-save-restore-state\/","title":{"rendered":"iGalcon &#8211; main menu + confusion over save \/ restore state"},"content":{"rendered":"<p>The good news: I&#8217;ve got the basic layout of my main menu decided on.  It isn&#8217;t really functional yet, but here it is:<\/p>\n<p><a href=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2008\/06\/igalcon7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-131\" title=\"igalcon7\" src=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2008\/06\/igalcon7-200x300.png\" alt=\"\" width=\"200\" height=\"300\" srcset=\"https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2008\/06\/igalcon7-200x300.png 200w, https:\/\/www.philhassey.com\/blog\/wp-content\/uploads\/2008\/06\/igalcon7.png 320w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a><\/p>\n<p>I&#8217;ve also got the game transitioning between several states and prompts now.  I haven&#8217;t coded in the difficulty levels or the various missions quite yet, will be doing that soon.  I&#8217;ve also got it saving and restoring game state when you quit the game and start it up again.  (That way, if you get a phone call you can resume your game exactly where you left off after talking &#8230;)<\/p>\n<p>Here&#8217;s the trouble: I can&#8217;t figure out how to write and read files on the iphone.  I want to do this with C code:<\/p>\n<p>void gc_engine_save(gc_game *g) {<br \/>\nFILE *f;<br \/>\nint ver = GC_VERSION;<br \/>\nf = fopen(&#8220;igalcon.sav&#8221;,&#8221;wb&#8221;);<br \/>\nfwrite(&amp;ver,sizeof(int),1,f);<br \/>\nfwrite(g,sizeof(gc_game),1,f);<br \/>\nfclose(f);<br \/>\n}<\/p>\n<p>And be able to load it later, etc .. However, the iphone gives me a EXC_BAD_ACCESS error .. I guess because I can&#8217;t just write to just anywhere.  What would be nice is if I knew what path to write to, however my brain has found the API reference a bit huge for a noob to the whole Apple way of doing things.<\/p>\n<p>Rumors I&#8217;ve heard are &#8220;save your stuff to the Documents folder&#8221; or &#8220;no no, save it to the Library&#8221; or &#8220;no, you have to save it under $some_folder\/Galcon\/&#8221; or &#8220;it&#8217;s best to save your settings via some NSSettings &#8230;blah blah&#8221; .  I&#8217;m sure I could get it working one of those ways, I just want to know *which* one I should use.  And maybe a link to an example.  Basically, what I want to do is in my ObjC code is construct a base path, send it to my C code and be able to do something like char fname[256]; sprintf(fname,&#8221;%s\/igalcon.sav&#8221;,base_path); And then carry on with what I was trying to do ..<\/p>\n<p>And .. if everything I&#8217;ve just said sounds like a really bad idea, I&#8217;d be thrilled for some guidance on this point \ud83d\ude42  In the meantime, I think I&#8217;ll get some more bots working and whatnot.  I&#8217;m trying to decide if I should use tinypy or not for some of the code, but at present, I&#8217;m leaning towards just coding up my bots \/ missions in C code for the iphone.<\/p>\n<p>P.S. while you&#8217;re at it, if someone can explain what the purpose of these methods of UIApplicationDelegate and how to make them happen on my ipod touch, I&#8217;d really appreciate it.<\/p>\n<p>Responding to a Change in Active Status<\/p>\n<p>* \u2013 applicationWillResignActive:\u00a0 optional method<br \/>\n* \u2013 applicationDidBecomeActive:\u00a0 optional method<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The good news: I&#8217;ve got the basic layout of my main menu decided on. It isn&#8217;t really functional yet, but here it is: I&#8217;ve also got the game transitioning between several states and prompts now. I haven&#8217;t coded in the difficulty levels or the various missions quite yet, will be doing that soon. I&#8217;ve also [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,66],"tags":[],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-galcon","category-iphone"],"_links":{"self":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":0,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}