> I thought UK did use the military to prevent Northern Ireland from splitting off.
You may be thinking of the UK military being in Northern Ireland to try to keep the peace from a population that were attempting to kill each other in the 70s?
However if you're talking about the 1916-1922 period:
Some people in Dublin declared independence in the "Easter Uprising" (in the middle of a war) over 100 years ago, it was dealt with by the UK military. The second attempt in 1918 was far better -- there was a massive democratic will for independence expressed through the ballot box. The UK government (100 years ago) resisted this independence initially, which was wrong, just as wrong as Spain resiting Catalan independence.
Eventually the UK government relented, and granted independence to Ireland after free and democratic elections in 1921, when 98% of the voters in what's now called "Ireland" voted for the pro-indepedence Sinn Fein (it was unopposed in almost every constituency)
However in the north, many residents did not want to become independent from the UK. The election there returned 67% in favour of the unionist party. As such independence was offered to the entire island, but the north could opt out by having it's parliament ask to (through it's democratically elected parliament). They did - the day after the Irish Free state came into being.
So people who lived in each area got to choose where they wanted to be, and all was well. That's how it should be for Scotland, and Catalonia.
The messy business of unpicking a country began (including a brief 'civil' war), but by 1937 the Irish government in Dublin ratified a constitution. This constitution claimed sovereignty over the north as well, despite the population in the North not wanting that, which wasn't exactly a good way to make friends and influence people.
It was only in 1998 that Dublin agreed to remove this claim from their constitution, and agree that whether the north should be moved from Britain to Ireland was a matter for people who live in the north (and indeed one for those in the south, who would have to agree to take them)