The wing folding mechanisms (in aircraft) and rotor folding mechanisms (in helicopters) are different. The V-22 Osprey falls somewhere in the middle.
- In case of aircraft, the wing folding mechanism is usually made of high grade steel (or titanium in some cases) and actuated either hydraulically (or in recent cases) electrically. The outer wing rotates about a hinge, to which the two parts (inboard and outboard) of the wings are locked. For example, the F/A 18 wing folding mechanism looks something like this:
Image from US Patent Wing fold push-pin locking assembly US 5558299 A
In general, once the wings are either folded (or unfolded), they are locked using very hefty sliding pins which provide a secure mechanical connection once (they) slid into place in sockets in the outer wing.
However, incidents do happen, usually because the pins have not locked and not because of failure. A number of incidents have happened where aircraft have taken off with wings folded (and landed safely, surprisingly).
Source : reddit.com/theaviationist.com
- In case of helicopters, the blade folding method is more or less the same with some variations- pull the pin that holds the blade (on one side) and fold the blades, which is done manually for small helicopters and hydraulically for large ones.
They are then held either by hydraulic pressure or mechanical attachments.
At-least in helicopters, there is little chance of a takeoff with the wings folded.
The V-22 Osprey is a special case- The propellers (or rotors) is folded first, then the engines are rotated, followed by the wings themselves.