?
Solved

FireMonkey - Using NSFileManager in Free Pascal Compiler

Posted on 2012-09-04
10
Medium Priority
?
1,401 Views
Last Modified: 2012-09-06
Hello Experts,

When searching for a path in Mac OSX, I was advised to use a FileManager method like URLForDirectory. When I do this for OSX, I reference (in the "uses" statement) the "MacAPI.Foundation module" and it works as expected. Unfortunately, when iOS is the target platform, this doesn’t work in the xcode free pascal compiler. Instead, xcode returns the error: 'Identifier not found "NSFileManager"' together with other errors all of which are related to NSFileManager.

In the "uses" statement, I tried replacing the dot with an underscore like all the other FMX modules do (ie. “MacAPI_Foundation”), but that didn’t work either. I searched the Mac folder where FireMonkey stores all its support PAS files, but nothing looked familiar. When I Googled the problem the search results were not exactly on point. I presume I need to include the correct module in the "uses" statement. Does anyone know the correct corresponding module to place in the "uses" clause when programming for iOS in order to access the path-finding functions?
0
Comment
Question by:efz
  • 6
  • 4
10 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 38371566
Have you already tried unit iphoneall...

uses iphoneall,...

Open in new window

0
 

Author Comment

by:efz
ID: 38371933
Yes, that didn't work. I ended up finding references to NSFileManager in a ".inc" file, but from my past programming experience I was not familiar with the use of that file type in a Delphi Pascal program.
0
 
LVL 19

Expert Comment

by:Thommy
ID: 38372079
Have you already tried unit FMX_Platform_iOS?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:efz
ID: 38372146
The FMX_Platform_iOS module was a good guess, but incorrect. I have since learned that all the iOS units are placed by Embarcadero in the fmi folder. When I searched the text of FMX_Platform_iOS.pas there was no reference to NSFileManager and thus the error. I also searched the text of all the pas units in the fmi folder and likewise there was no reference. Now I'm beginning to think I'm barking up the wrong tree and that iOS may not have provision for direct folder access like OS X and Windows, i.e., the sandbox thing.

I'm reading a book on FireMonkey for iOS by Graeme Chandler that may shed some light on this subject.

The reason I have this question in the first place is because I customarily use a form that dynamically populates with controls that it loads from a file at run time. So, if I can't place the files on an iPad for instance and read them in at run time, my normal technique won't work.
0
 
LVL 19

Accepted Solution

by:
Thommy earned 2000 total points
ID: 38372198
Try it again with iphoneall.pas.

I think iphoneall.pas is not in the fmi folder, but somewhere in the /fpc/... folder.

Include this path in your compiler search path and give it another try...
0
 

Author Comment

by:efz
ID: 38372507
When I tried adding FMX_Platform_iOS to the uses statement, I never removed iPhoneAll which I had previously tried. So, it's still not resolving the identification error. Also, I noted that there is no error related to the actual insertion of FMX_Platform_iOS and iPhoneAll in the uses clause so the compiler must be finding the units themselves.

I jumped forward to the section of Chandler's book where he mentions NSFileManager, but his examples excerpt code wtihout showing the uses statement. I think there are complete code samples available and I'll check those.
0
 

Author Comment

by:efz
ID: 38372541
Thommy,

The Chandler example is using iPhoneAll in the uses clause as you suspected.

I guess my job now will be to find out why I'm getting the error. Again, surprisingly, I'm not getting an error related to iPhoneAll in the uses statement, so that's confusing me. If the compiler's finding iPhoneAll, why isn't able to find the NSFileManager declaration?
0
 

Author Comment

by:efz
ID: 38372743
Two things.

One. I found the iPhoneAll.pas file and there is definitely a NSFileManager declaration contained within.

Two. I also located Chandler's demo code. The uses statement reference the iPhoneAll as you correctly suggested, and above the uses statement was the following:

{IFDEF FPC}
{$modeswitch objectivec1}
{$ENDIF FPC}

I included it, but damn if I still didn't get the error "cannot find identifier NSFileManager." I must be living under a cloud.

Any final suggestions before I issue the points to you?
0
 

Author Comment

by:efz
ID: 38374017
For interested parties, Thommy's suggestion was spot on.

What continued to cause the error was the fact that the syntax for OS X and iOS was slightly different and because I didn't disclose my code, I wasn't giving Thommy much of a clue. In order to follow up on his advice I located some demo code that is included with Chandler's book (a must-have if you're coming to iOS via FireMonkey) that demonstrated the technique for querying directory paths in iOS.

Thanks Thommy.
0
 
LVL 19

Expert Comment

by:Thommy
ID: 38375070
I will also have a look at Graeme Chandler's book.

Thank you very much for the points!!!
:o)))
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Screencast - Getting to Know the Pipeline
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question