how do I parse a mail in Cocoa?
I've read the NSScanner tutorial, but struggled.
Do you know any better way than NSScanner?
Is there any sample code?
My example:
http://pastie.org/private/pordph27stkwkyvrx2tiq
Regards
If you cannot find any cocoa libraries to do the job you need done, you can always use C++ or C libraries for your tasks. e.g. Scaling Web's Parser. Apple has documentation on how to use C++ from Objective C
I use C-Client. It's C only, a bit hard to understand but it gets the job done.
I wouldn't take on writing a MIME parser myself - it's lots of work if you look at the RFCs that come into play.
Related
I'm in search of a framework, which allows to parse *.elmx email files of Apple.Mail.
Ultimately, I'd like to extract attachments from emails.
Unfortunately, I'm not aware of such a framework. Are you?
PS: For general parsing problems, ParseKit looks promising.
There is an open-source solution written almost entirely in objective-c called Pantomime although probably dated. Here's the link.
Consider using AppleScript and Automator and integrate the AppleScript in your Cocoa app.
Similar example here, http://hintsforums.macworld.com/showthread.php?t=95583
is there any Objective C library for parsing HTML, like python's BeautifulSoup? Thanks
From Apple's part there is NSXMLDocument and NSXMLParser, which support tidied HTML input. (Tree-Based XML Programming Guide)
On iOS (4.3) there's currently no NSXMLDocument available, so you'd have to use either NSXMLParser or libxml2.2.
Some more informations on potential problems with parsing malformed HTML:
What's the best approach for parsing XML/'screen scraping' in iOS? UIWebview or NSXMLParser?
The most reliable solution is to use an off-screen WebView, load the HTML source into it and then access its DOM tree.
The best way I have found is NSXMLParser + libtidy. However, there are many third party libraries are available now which makes parsing easier. (last answer was written in 2011).
Google's Gumbo HTML5 parser is pretty good. It's written in pure C99 and you can use it with Objective C (use a wrapper like this one).
If you want pure Objective C libraries then Ono or hpple are good. HTMLReader is also a good alternative.
If Swift is your thing, you could use NDHpple which is a swift wrapper based on hpple. Or You could use Swift-HTML-Parser. (Bonus: Alamofire is as good as Python Requests and is a joy to use)
I've been using objective C for a while now, and I've started learning some of the lower level iPhone API's such as core audio. Most of these API's are in C which is confusing me a bit, I'm not sure where to put a lot of code and I don't know the rules, etc. Does anyone know where a good place to start learning this is?
Thanks, Darren.
You can write C inline inside any Objective C method. You can also define functions in a .c file and their prototypes in a .h file which you can then include into any ObjectiveC .m file and call from within Objective C code.
Does anyone know where a good place to start learning this is?
Buy and read "The C Programming Language". It's not very long and surprisingly enjoyable.
Read and understand Apple's C-based example code.
Browse the header files for Apple's classes. This is a great way to learn how apple sets up enums and string constants, etc.
Doing these three things won't make you an expert in C, but it'll give you 90% of what you need to be able to confidently get things done with Apple's low level frameworks.
Objective-C is a superset of classic C, which means you have access to everything C as well as everything implemented in Objective-C. You can write in both if you wish.
Are there some particular library files available on OS/X that are relevant, I am just not sure where to start.
You'd probably want to use the QuickTime for that. There is some sample code that does this. However, it's not the nicest way to access metadata. The newer QTKit Framework somehow still requires you to fall back to the C-based APIs. There is another example from Apple embedding meta data writing into a Objective-C method. This might be the best starting point for you.
I was wondering if there were a way to extract information from an objective-c app, static or dynamic library and/or framework?
Information such as an array of class names without instantiating or running the target.
I've checked google and the apple developer documentation and haven't found anything.
Frank
F-script appears to be able to do what you want, but I'm no expert. Check out www.fscript.org.
If you want to extract classes from an application/dynamic library, there is a handy tool called ClassDump.
It can even generate the header files in order to get an overview of the classes, protocols, etc.
If you want to do it at runtime, then take a look at the source code to learn how to load and parse the different mach-o segments.
This is an excellent starting point for reverse-engineering Cocoa apps:
http://culater.net/wiki/moin.cgi/CocoaReverseEngineering
It mentions F-Script, class-dump, and a few others.