Sorry -- I'm confused.
A light installed before drywall goes up will have the box attached to the frame and it will be wired in-place. It will have an approved whip to whatever holds the bulb. The wipe may cary 12v or 120 depening on the fixture. A remodel fixture will have a junction box where the high voltage cable can be attached and it's attached to the can in some way as to go into the hole -- these also have whip.
Here's what I'm seeing in the house where I'm working:
The can lights were remodels, but access panels were cut into the drywall during installation (and later patched) to get everything into the ceiling.
There is a metal frame that braces between the trusses. That metal frame has a ring attached to it, onto which the can mounts with three screws. About five inches away from the can, a box is mounted to that metal frame, inside of which the splices to the 110v are made. That runs to a transformer which is attached to the outside of the box and steps the voltage down to 12v. A whip carries the 12v into the can, where it connects to the trim kit with a halogen socket.
So, the box is only accessible by removing the can.
I was originally replying to someone who seemed to be saying that it's not code to have a box that's only accessible by removing a can. I don't believe that person's statement is correct. Your first example (a box attached to the frame with a whip) would support my assertion. Also, someone else pointed out that the code only requires that no part of the building have to be removed to access the box. A can isn't really part of the building.