Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Sequence Protocol #56

Open
shnabz opened this issue Jun 13, 2017 · 5 comments
Open

Sequence Protocol #56

shnabz opened this issue Jun 13, 2017 · 5 comments

Comments

@shnabz
Copy link

shnabz commented Jun 13, 2017

Hi, when trying to iterate through the form container I get:
Type 'ILPDFFormContainer?' does not conform to protocol 'Sequence'
Any thoughts?

@fboemeke
Copy link

Any idea? I have the same problem!

@shnabz
Copy link
Author

shnabz commented Jul 18, 2017

I have ended up opening my pdf in Adobe Acrobat and making a note of all the form fields ID, I then use these strings to refer to the form fields which works fine.

@fboemeke
Copy link

Thanks @shnabz! I've used the same solution although I'm looking for a dynamic solution.

@shnabz
Copy link
Author

shnabz commented Jul 18, 2017

@fboemeke I've found a solution! Add this extension to your .swift file.

extension ILPDFFormContainer: Sequence {
    public func makeIterator() -> NSFastEnumerationIterator {
        return NSFastEnumerationIterator(self as NSFastEnumeration)
    }
}

You can then do:

for form in document.forms {
    let x = form as! ILPDFForm
    print(x.name)
}

@fboemeke
Copy link

@shnabz Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants